Skip to content

Commit 2729dd5

Browse files
authored
Merge pull request #991 from JuliaControl/plotlabels
provide signal names to SimResult plot
2 parents 967cab7 + de72455 commit 2729dd5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/ControlSystemsBase/src/plotting.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ end
102102

103103

104104
# This will be called on plot(lsim(sys, args...))
105-
@recipe function simresultplot(r::SimResult; plotu=false, plotx=false, ploty=true)
105+
@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))
106106
ny, nu, nx, sys = r.ny, r.nu, r.nx, r.sys
107107
t = r.t
108108
n_series = size(r.y, 3) # step and impulse produce multiple results
@@ -115,11 +115,11 @@ end
115115
if ploty
116116
for ms in 1:n_series
117117
for i=1:ny
118-
ytext = output_names(sys, i)
118+
ytext = output_names[i]
119119
@series begin
120120
xguide --> "Time (s)"
121121
yguide --> ytext
122-
label --> (n_series > 1 ? "From $(input_names(sys, ms))" : "")
122+
label --> (n_series > 1 ? "From $(input_names[ms])" : "")
123123
subplot --> i
124124
t, r.y[i, :, ms]
125125
end
@@ -129,7 +129,7 @@ end
129129
end
130130
if plotu # bug in recipe system, can't use `plotu || return`
131131
for i=1:nu
132-
utext = input_names(sys, i)
132+
utext = input_names[i]
133133
@series begin
134134
xguide --> "Time (s)"
135135
yguide --> utext
@@ -142,7 +142,7 @@ end
142142
end
143143
if plotx
144144
for i=1:nx
145-
xtext = state_names(sys, i)
145+
xtext = state_names[i]
146146
@series begin
147147
xguide --> "Time (s)"
148148
yguide --> xtext

0 commit comments

Comments
 (0)