Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad996f9

Browse files
authored
Merge pull request#1138 from lkies/fix-svp
Fix color cycling not working in singular_values_plot
2 parents45a6a2a +049a716 commitad996f9

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

‎control/freqplot.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,12 +2556,12 @@ def singular_values_plot(
25562556
nyq_freq=None
25572557

25582558
# Determine the color to use for this response
2559-
color=_get_color(
2559+
current_color=_get_color(
25602560
color,fmt=fmt,offset=color_offset+idx_sys,
25612561
color_cycle=color_cycle)
25622562

25632563
# To avoid conflict with *fmt, only pass color kw if non-None
2564-
color_arg= {}ifcolorisNoneelse {'color':color}
2564+
color_arg= {}ifcurrent_colorisNoneelse {'color':current_color}
25652565

25662566
# Decide on the system name
25672567
sysname=response.sysnameifresponse.sysnameisnotNone \

‎control/tests/freqplot_test.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,39 @@ def test_display_margins(nsys, display_margins, gridkw, match):
680680
assertcplt.axes[0,0].get_title()==''
681681

682682

683+
deftest_singular_values_plot_colors():
684+
# Define some systems for testing
685+
sys1=ct.rss(4,2,2,strictly_proper=True)
686+
sys2=ct.rss(4,2,2,strictly_proper=True)
687+
688+
# Get the default color cycle
689+
color_cycle=plt.rcParams['axes.prop_cycle'].by_key()['color']
690+
691+
# Plot the systems individually and make sure line colors are OK
692+
cplt=ct.singular_values_plot(sys1)
693+
assertcplt.lines.size==1
694+
assertlen(cplt.lines[0])==2
695+
assertcplt.lines[0][0].get_color()==color_cycle[0]
696+
assertcplt.lines[0][1].get_color()==color_cycle[0]
697+
698+
cplt=ct.singular_values_plot(sys2)
699+
assertcplt.lines.size==1
700+
assertlen(cplt.lines[0])==2
701+
assertcplt.lines[0][0].get_color()==color_cycle[1]
702+
assertcplt.lines[0][1].get_color()==color_cycle[1]
703+
plt.close('all')
704+
705+
# Plot the systems as a list and make sure colors are OK
706+
cplt=ct.singular_values_plot([sys1,sys2])
707+
assertcplt.lines.size==2
708+
assertlen(cplt.lines[0])==2
709+
assertlen(cplt.lines[1])==2
710+
assertcplt.lines[0][0].get_color()==color_cycle[0]
711+
assertcplt.lines[0][1].get_color()==color_cycle[0]
712+
assertcplt.lines[1][0].get_color()==color_cycle[1]
713+
assertcplt.lines[1][1].get_color()==color_cycle[1]
714+
715+
683716
if__name__=="__main__":
684717
#
685718
# Interactive mode: generate plots for manual viewing

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp