Skip to content

Commit 1a451a9

Browse files
authored
Merge pull request #120 from JuliaControl/fixplot
Avoid introducing MPC.plot
2 parents c81fb37 + 071f134 commit 1a451a9

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

docs/src/manual/nonlinmpc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ savefig("plot1_NonLinMPC.svg"); nothing # hide
8181
![plot1_NonLinMPC](plot1_NonLinMPC.svg)
8282

8383
The [`setname!`](@ref) function allows customized Y-axis labels. The available plotting
84-
options are detailed in the documentation of the corresponding [`plot`](@ref ModelPredictiveControl.plot)
84+
options are detailed in the documentation of the corresponding [`plot`](@ref ModelPredictiveControl.plot_recipe)
8585
method.
8686

8787
## Nonlinear Model Predictive Controller

docs/src/public/plot_sim.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ The `plot` methods are based on [`Plots.jl`](https://github.com/JuliaPlots/Plots
2828
To install it run `using Pkg; Pkg.add("Plots")` in the Julia REPL.
2929

3030
```@docs
31-
ModelPredictiveControl.plot
31+
ModelPredictiveControl.plot_recipe
3232
```

src/plot_sim.jl

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,13 @@ end
318318
"Keep manipulated input `u` unchanged for state estimator simulation."
319319
sim_getu!(::StateEstimator, u, _ , _ ) = u
320320

321-
322-
# dummy plot methods to document recipes (both in ?-mode and web documentation)
323-
plot(::Nothing, ::SimResult{<:Real, <:SimModel}) = nothing
324-
plot(::Nothing, ::SimResult{<:Real, <:StateEstimator}) = nothing
325-
plot(::Nothing, ::SimResult{<:Real, <:PredictiveController}) = nothing
321+
function get_indices(arg::IntRangeOrVector, n)
322+
if length(unique(arg)) length(arg) || maximum(arg) > n
323+
error("Plot keyword argument arguments should contains valid and unique indices")
324+
end
325+
return arg
326+
end
327+
get_indices(arg::Bool, n) = arg ? (1:n) : Int64[]
326328

327329
@doc raw"""
328330
plot(res::SimResult{<:Real, <:SimModel}; <keyword arguments>)
@@ -348,15 +350,7 @@ julia> using Plots; plot(res, plotu=false)
348350
```
349351
![plot_model](../assets/plot_model.svg)
350352
"""
351-
plot(::Nothing, ::SimResult{<:Real, <:SimModel})
352-
353-
function get_indices(arg::IntRangeOrVector, n)
354-
if length(unique(arg)) length(arg) || maximum(arg) > n
355-
error("Plot keyword argument arguments should contains valid and unique indices")
356-
end
357-
return arg
358-
end
359-
get_indices(arg::Bool, n) = arg ? (1:n) : Int64[]
353+
plot_recipe(::Nothing, ::SimResult{<:Real, <:SimModel}) = nothing
360354

361355
@recipe function plot_recipe(
362356
res::SimResult{<:Real, <:SimModel};
@@ -468,7 +462,7 @@ Plot the simulation results of a [`StateEstimator`](@ref).
468462
if applicable
469463
- `plotx̂max=true` or *`plotxhatmax`* : plot estimated state upper bounds ``\mathbf{x̂_{max}}``
470464
if applicable
471-
- `<keyword arguments>` of [`plot(::SimResult{<:Real, <:SimModel})`](@ref)
465+
- `<keyword arguments>` of [`plot(::SimResult{<:Real, <:SimModel})`](@ref plot_recipe)
472466
473467
# Examples
474468
```julia-repl
@@ -478,7 +472,7 @@ julia> using Plots; plot(res, plotu=false, plotŷ=true, plotxwithx̂=true)
478472
```
479473
![plot_estimator](../assets/plot_estimator.svg)
480474
"""
481-
plot(::Nothing, ::SimResult{<:Real, <:StateEstimator})
475+
plot_recipe(::Nothing, ::SimResult{<:Real, <:StateEstimator}) = nothing
482476

483477
@recipe function plot_recipe(
484478
res::SimResult{<:Real, <:StateEstimator};
@@ -726,8 +720,8 @@ Plot the simulation results of a [`PredictiveController`](@ref).
726720
- `plotru=true` : plot manipulated input setpoints ``\mathbf{r_u}`` if applicable
727721
- `plotumin=true` : plot manipulated input lower bounds ``\mathbf{u_{min}}`` if applicable
728722
- `plotumax=true` : plot manipulated input upper bounds ``\mathbf{u_{max}}`` if applicable
729-
- `<keyword arguments>` of [`plot(::SimResult{<:Real, <:SimModel})`](@ref)
730-
- `<keyword arguments>` of [`plot(::SimResult{<:Real, <:StateEstimator})`](@ref)
723+
- `<keyword arguments>` of [`plot(::SimResult{<:Real, <:SimModel})`](@ref plot_recipe)
724+
- `<keyword arguments>` of [`plot(::SimResult{<:Real, <:StateEstimator})`](@ref plot_recipe)
731725
732726
# Examples
733727
```julia-repl
@@ -739,7 +733,7 @@ julia> using Plots; plot(res, plotŷ=true, plotry=true, plotumax=true, plotx̂=
739733
```
740734
![plot_controller](../assets/plot_controller.svg)
741735
"""
742-
plot(::Nothing, ::SimResult{<:Real, <:PredictiveController})
736+
plot_recipe(::Nothing, ::SimResult{<:Real, <:PredictiveController}) = nothing
743737

744738
@recipe function plot_recipe(
745739
res::SimResult{<:Real, <:PredictiveController};

0 commit comments

Comments
 (0)