Skip to content

Commit 0c2c1c2

Browse files
authored
Merge pull request #64 from control-toolbox/extension-plot
up ext plot
2 parents 7ae901b + af48b34 commit 0c2c1c2

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CTModels"
22
uuid = "34c4fa32-2049-4079-8329-de33c2a22e2d"
33
authors = ["Olivier Cots <olivier.cots@toulouse-inp.fr>"]
4-
version = "0.2.1"
4+
version = "0.2.2"
55

66
[deps]
77
CTBase = "54762871-cc72-4466-b8e8-f6c8b58076cd"
@@ -12,6 +12,7 @@ MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
1212
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1313
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
1414
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
15+
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1516

1617
[weakdeps]
1718
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
@@ -34,4 +35,5 @@ MacroTools = "0.5"
3435
Parameters = "0.12"
3536
Plots = "1.40"
3637
PrettyTables = "2.4"
38+
RecipesBase = "1.3"
3739
julia = "1.10"

src/CTModels.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using MLStyle
99
using Parameters # @with_kw: to have default values in struct
1010
using MacroTools: striplines
1111
using PrettyTables # To print a table
12+
import RecipesBase: plot, plot!, RecipesBase
1213

1314
# aliases
1415
const Dimension = Int
@@ -29,6 +30,16 @@ import_ocp_solution(args...; kwargs...) = throw(CTBase.ExtensionError(:JLD2, :JS
2930
include("default.jl")
3031
include("utils.jl")
3132
include("types.jl")
33+
34+
# to be extended
35+
function RecipesBase.plot(sol::AbstractSolution; kwargs...)
36+
throw(CTBase.ExtensionError(:Plots))
37+
end
38+
function RecipesBase.plot!(p::RecipesBase.AbstractPlot, sol::AbstractSolution; kwargs...)
39+
throw(CTBase.ExtensionError(:Plots))
40+
end
41+
42+
#
3243
include("init.jl")
3344
include("dual_model.jl")
3445
include("state.jl")
@@ -42,4 +53,7 @@ include("print.jl")
4253
include("model.jl")
4354
include("solution.jl")
4455

56+
#
57+
export plot, plot!
58+
4559
end

test/extras/plot_manual.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@ plot!(plt, sol; time=:default, state_style=style, costate_style=style, control_s
173173
plt = plot(sol; layout=:group, control=:components)
174174
plot!(plt, sol; layout=:group, control=:components)
175175
plot!(plt, sol; layout=:group, control=:norm)
176-
plot!(plt, sol; layout=:group, control=:all)
176+
#plot!(plt, sol; layout=:group, control=:all)

test/solution_test.jld2

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)