Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requires #163

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions ext/CTBasePlots.jl
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions src/plot.jl → ext/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions src/CTBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -205,7 +204,6 @@ include("utils.jl")
include("checking.jl")
#
include("print.jl")
include("plot.jl")
#
include("functions.jl")
include("model.jl")
Expand Down Expand Up @@ -254,7 +252,6 @@ export nlp_constraints, constraints_labels

# solution
export OptimalControlSolution
export plot, plot!

# initialization
export OCPInit
Expand Down
1 change: 1 addition & 0 deletions test/test_plot_joseph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# a la main
using CTBase
using PlotUtils

n=1
m=1
Expand Down
2 changes: 1 addition & 1 deletion test/test_plot_manual.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using CTBase
#using Plots
using Plots

layout = :split
size = (900, 600)
Expand Down
Loading