Skip to content

Commit c753e04

Browse files
authored
Update plot.jl
1 parent 2539b9c commit c753e04

1 file changed

Lines changed: 33 additions & 29 deletions

File tree

ext/plot.jl

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,61 +1176,61 @@ end
11761176
"""
11771177
$(TYPEDSIGNATURES)
11781178
1179-
Plot the components of an optimal control `Solution`.
1179+
Plot the components of an optimal control solution.
11801180
11811181
This is the main user-facing function to visualize the solution of an optimal control problem
11821182
solved with the control-toolbox ecosystem.
11831183
1184-
It generates a plot (or set of subplots) showing the evolution of the state, control, costate,
1185-
path constraints, and dual variables over time, depending on the user’s choices.
1184+
It generates a set of subplots showing the evolution of the state, control, costate,
1185+
path constraints, and dual variables over time, depending on the problem and the user’s choices.
11861186
11871187
# Arguments
11881188
1189-
- `sol::CTModels.Solution`: The optimal control solution to visualize. Typically the result after solving a problem.
1189+
- `sol::CTModels.Solution`: The optimal control solution to visualise.
11901190
- `description::Symbol...`: A variable number of symbols indicating which components to include in the plot. Common values include:
1191-
- `:state` – plot the state trajectory.
1192-
- `:costate` – plot the costate (adjoint) variables.
1193-
- `:control` – plot the control signal.
1194-
- `:path` – plot the values of nonlinear path constraints.
1195-
- `:dual` – plot the dual variables (Lagrange multipliers) associated with path constraints.
1191+
- `:state` – plot the state.
1192+
- `:costate` – plot the costate (adjoint).
1193+
- `:control` – plot the control.
1194+
- `:path` – plot the path constraints.
1195+
- `:dual` – plot the dual variables (or Lagrange multipliers) associated with path constraints.
11961196
11971197
If no symbols are provided, a default set is used based on the problem and styles.
11981198
1199-
# Keyword Arguments
1199+
# Keyword Arguments (Optional)
12001200
12011201
- `layout::Symbol = :group`: Specifies how to arrange plots.
12021202
- `:group`: Fewer plots, grouping similar variables together (e.g., all states in one subplot).
12031203
- `:split`: One plot per variable component, stacked in a layout.
12041204
12051205
- `control::Symbol = :components`: Defines how to represent control inputs.
12061206
- `:components`: One curve per control component.
1207-
- `:norm`: Single curve showing ‖u(t)‖.
1207+
- `:norm`: Single curve showing the Euclidean norm ‖u(t)‖.
12081208
- `:all`: Plot both components and norm.
12091209
1210-
- `time::Symbol = :default`: Time normalization for plots.
1210+
- `time::Symbol = :default`: Time normalisation for plots.
12111211
- `:default`: Real time scale.
1212-
- `:normalize` or `:normalise`: Normalized to the interval [0, 1].
1212+
- `:normalize` or `:normalise`: Normalised to the interval [0, 1].
12131213
12141214
- `solution_label::String = ""`: Label to annotate this solution in the legend. (Deprecated: use `label` instead)
12151215
12161216
## Style Options (Optional)
12171217
1218-
All style-related keyword arguments can be either a `NamedTuple` of plotting attributes or the `Symbol` `:none` referring to not plot the associated element. These allow you to customize color, line style, markers, etc.
1218+
All style-related keyword arguments can be either a `NamedTuple` of plotting attributes or the `Symbol` `:none` referring to not plot the associated element. These allow you to customise color, line style, markers, etc.
12191219
1220-
- `state_style`: Plot style for state components.
1221-
- `costate_style`: Plot style for costate components.
1222-
- `control_style`: Plot style for control components.
1223-
- `dual_style`: Plot style for dual variables.
1224-
- `path_style`: Plot style for path constraint values.
1220+
- `time_style`: Style for vertical lines at initial and final time.
1221+
- `state_style`: Style for state components.
1222+
- `costate_style`: Style for costate components.
1223+
- `control_style`: Style for control components.
1224+
- `path_style`: Style for path constraint values.
1225+
- `dual_style`: Style for dual variables.
12251226
12261227
## Bounds Decorations (Optional)
12271228
1228-
Use these options to show bounds on the plots if applicable and defined in the model. If set to `:none` then it is not shown on the plots.
1229+
Use these options to customise bounds on the plots if applicable and defined in the model. Set to `:none` to hide.
12291230
1230-
- `state_bounds_style`: Style for state variable bounds.
1231+
- `state_bounds_style`: Style for state bounds.
12311232
- `control_bounds_style`: Style for control bounds.
12321233
- `path_bounds_style`: Style for path constraint bounds.
1233-
- `time_style`: Style for vertical lines at initial and final time.
12341234
12351235
# Returns
12361236
@@ -1239,15 +1239,19 @@ Use these options to show bounds on the plots if applicable and defined in the m
12391239
# Example
12401240
12411241
```julia-repl
1242-
# plot the state and control with default layout
1242+
# basic plot
1243+
julia> plot(sol)
1244+
1245+
# plot only the state and control
12431246
julia> plot(sol, :state, :control)
12441247
1245-
# customize layout and styles
1246-
julia> plot(sol, :state, :control;
1247-
layout = :split,
1248-
control = :all,
1249-
state_style = (color=:blue, linestyle=:solid),
1250-
control_style = (color=:red, linestyle=:dash))
1248+
# customise layout and styles, no costate
1249+
julia> plot(sol;
1250+
layout = :split,
1251+
control = :all,
1252+
state_style = (color=:blue, linestyle=:solid),
1253+
control_style = (color=:red, linestyle=:dash),
1254+
costate_style = :none)
12511255
```
12521256
"""
12531257
function Plots.plot(

0 commit comments

Comments
 (0)