Skip to content

Commit a7a39ae

Browse files
committed
style may be :none
1 parent 052aa52 commit a7a39ae

6 files changed

Lines changed: 302 additions & 121 deletions

File tree

ext/CTModelsPlots.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using Plots # redefine plot, plot!
1212
using Plots.Measures
1313
#import Plots: plot, plot!
1414

15+
include("plot_utils.jl")
1516
include("default.jl")
1617
include("plot.jl")
1718

ext/default.jl

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,47 @@ $(TYPEDSIGNATURES)
2929
__description() = (:state, :states,
3030
:costate, :costates,
3131
:control, :controls,
32-
:constraint, :constraints, :cons,
32+
:constraint, :constraints, :cons, :path,
3333
:dual, :duals)
3434

3535
"""
3636
$(TYPEDSIGNATURES)
3737
38-
"""
39-
function clean(description)
40-
# remove the nouns in plural form
41-
description = replace(description,
42-
:states => :state,
43-
:costates => :costate,
44-
:controls => :control,
45-
:constraints => :cons,
46-
:constraint => :cons,
47-
:duals => :dual)
48-
# remove the duplicates
49-
return tuple(Set(description)...)
50-
end
51-
52-
"""
53-
$(TYPEDSIGNATURES)
54-
5538
Used to set the default value of the plot size.
5639
"""
5740
function __size_plot(
5841
sol::CTModels.Solution,
5942
model::Union{CTModels.Model,Nothing},
6043
control::Symbol,
6144
layout::Symbol,
62-
description::Symbol...
45+
description::Symbol...;
46+
state_style::Union{NamedTuple, Symbol},
47+
control_style::Union{NamedTuple, Symbol},
48+
costate_style::Union{NamedTuple, Symbol},
49+
path_style::Union{NamedTuple, Symbol},
50+
dual_style::Union{NamedTuple, Symbol},
6351
)
6452

6553
# set the default description if not given and then clean it
6654
description = description == () ? __description() : description
6755
description = clean(description)
6856

57+
# check what to plot
58+
do_plot_state, do_plot_costate, do_plot_control, do_plot_path, do_plot_dual = do_plot(
59+
description...;
60+
state_style=state_style,
61+
control_style=control_style,
62+
costate_style=costate_style,
63+
path_style=path_style,
64+
dual_style=dual_style
65+
)
66+
6967
#
7068
if layout == :group
7169
nb_plots = 0
72-
nb_plots += :state description ? 1 : 0
73-
nb_plots += :costate description ? 1 : 0
74-
if :control in description
70+
nb_plots += do_plot_state ? 1 : 0
71+
nb_plots += do_plot_costate ? 1 : 0
72+
if do_plot_control
7573
if control == :components || control == :norm
7674
nb_plots += 1
7775
elseif control === :all
@@ -98,9 +96,9 @@ function __size_plot(
9896
end
9997
nc = model === nothing ? 0 : CTModels.dim_path_constraints_nl(model)
10098
nb_lines = 0
101-
nb_lines += (:state description || :costate description) ? n : 0
102-
nb_lines += :control description ? l : 0
103-
nb_lines += (:cons description || :dual description) ? nc : 0
99+
nb_lines += (do_plot_state || do_plot_costate) ? n : 0
100+
nb_lines += do_plot_control ? l : 0
101+
nb_lines += (do_plot_path || do_plot_dual) ? nc : 0
104102
if nb_lines==1
105103
return (600, 280)
106104
elseif nb_lines==2

0 commit comments

Comments
 (0)