diff --git a/Project.toml b/Project.toml index 0a76d1a7..a60e2031 100644 --- a/Project.toml +++ b/Project.toml @@ -13,13 +13,18 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078" MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" ReplMaker = "b873ce64-0db9-51f5-a568-4457d8e49576" Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +[weakdeps] +Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" + +[extensions] +CTBasePlots = "Plots" + [compat] DataStructures = "0.18" DifferentiationInterface = "0.5" diff --git a/ext/CTBasePlots.jl b/ext/CTBasePlots.jl new file mode 100644 index 00000000..dd1e540e --- /dev/null +++ b/ext/CTBasePlots.jl @@ -0,0 +1,16 @@ +module CTBasePlots + + # + using DocStringExtensions + using MLStyle # pattern matching + + # + using CTBase + using Plots + using LinearAlgebra + import Plots: plot, plot! + + # -------------------------------------------------------------------------------------------------- + include("plot.jl") + +end \ No newline at end of file diff --git a/src/plot.jl b/ext/plot.jl similarity index 98% rename from src/plot.jl rename to ext/plot.jl index 5f5861ac..244424aa 100644 --- a/src/plot.jl +++ b/ext/plot.jl @@ -11,8 +11,8 @@ $(TYPEDEF) A leaf of a plot tree. """ struct PlotLeaf <: AbstractPlotTreeElement - value::Tuple{Symbol,Integer} - PlotLeaf(value::Tuple{Symbol,Integer}) = new(value) + value::Tuple{Symbol, Integer} + PlotLeaf(value::Tuple{Symbol, Integer}) = new(value) end """ @@ -402,7 +402,7 @@ function Plots.plot(sol::OptimalControlSolution; # p = __initial_plot(sol; layout=layout, control=control, size=size, kwargs...) # - return plot!(p, sol; layout=layout, control=control, time=time, solution_label=solution_label, + return Plots.plot!(p, sol; layout=layout, control=control, time=time, solution_label=solution_label, state_style=state_style, control_style=control_style, costate_style=costate_style, kwargs...) end diff --git a/src/CTBase.jl b/src/CTBase.jl index 7bd265b1..64dc27ef 100644 --- a/src/CTBase.jl +++ b/src/CTBase.jl @@ -19,7 +19,6 @@ import ForwardDiff using Interpolations: linear_interpolation, Line, Interpolations # for default interpolation using MLStyle # pattern matching using Parameters # @with_kw: to have default values in struct -using Plots using Printf # to print an Opt imalControlModel using DataStructures # OrderedDict for aliases using Unicode # unicode primitives @@ -205,7 +204,6 @@ include("utils.jl") include("checking.jl") # include("print.jl") -include("plot.jl") # include("functions.jl") include("model.jl") @@ -256,7 +254,6 @@ export dim_boundary_conditions, dim_control_constraints, dim_state_constraints, # solution export OptimalControlSolution -export plot, plot! # initialization export OptimalControlInit diff --git a/test/test_plot_joseph.jl b/test/test_plot_joseph.jl index fcb5c708..4908c9bc 100644 --- a/test/test_plot_joseph.jl +++ b/test/test_plot_joseph.jl @@ -17,6 +17,7 @@ # a la main using CTBase +using PlotUtils n=1 m=1 diff --git a/test/test_plot_manual.jl b/test/test_plot_manual.jl index e1467443..fbd67c01 100644 --- a/test/test_plot_manual.jl +++ b/test/test_plot_manual.jl @@ -1,5 +1,5 @@ using CTBase -#using Plots +using Plots layout = :split size = (900, 600)