Skip to content

provide signal names to SimResult plot #991

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions lib/ControlSystemsBase/src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@


# This will be called on plot(lsim(sys, args...))
@recipe function simresultplot(r::SimResult; plotu=false, plotx=false, ploty=true)
@recipe function simresultplot(r::SimResult; plotu=false, plotx=false, ploty=true, input_names=ControlSystemsBase.input_names(r.sys), output_names=ControlSystemsBase.output_names(r.sys), state_names=ControlSystemsBase.state_names(r.sys))

Check warning on line 105 in lib/ControlSystemsBase/src/plotting.jl

View check run for this annotation

Codecov / codecov/patch

lib/ControlSystemsBase/src/plotting.jl#L105

Added line #L105 was not covered by tests
ny, nu, nx, sys = r.ny, r.nu, r.nx, r.sys
t = r.t
n_series = size(r.y, 3) # step and impulse produce multiple results
Expand All @@ -115,11 +115,11 @@
if ploty
for ms in 1:n_series
for i=1:ny
ytext = output_names(sys, i)
ytext = output_names[i]
@series begin
xguide --> "Time (s)"
yguide --> ytext
label --> (n_series > 1 ? "From $(input_names(sys, ms))" : "")
label --> (n_series > 1 ? "From $(input_names[ms])" : "")
subplot --> i
t, r.y[i, :, ms]
end
Expand All @@ -129,7 +129,7 @@
end
if plotu # bug in recipe system, can't use `plotu || return`
for i=1:nu
utext = input_names(sys, i)
utext = input_names[i]
@series begin
xguide --> "Time (s)"
yguide --> utext
Expand All @@ -142,7 +142,7 @@
end
if plotx
for i=1:nx
xtext = state_names(sys, i)
xtext = state_names[i]
@series begin
xguide --> "Time (s)"
yguide --> xtext
Expand Down
Loading