Skip to content

Commit 5e405cc

Browse files
committed
don't strip common parts of labels if given explicitly
1 parent 606cf48 commit 5e405cc

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

control/freqplot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,9 @@ def gen_zero_centered_series(val_min, val_max, period):
10461046
# Get the labels to use, removing common strings
10471047
lines = [line for line in ax.get_lines()
10481048
if line.get_label()[0] != '_']
1049-
labels = _make_legend_labels([line.get_label() for line in lines])
1049+
labels = _make_legend_labels(
1050+
[line.get_label() for line in lines],
1051+
ignore_common=line_labels is not None)
10501052

10511053
# Generate the label, if needed
10521054
if len(labels) > 1 and legend_map[i, j] != None:

control/tests/freqplot_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@ def test_gangof4_trace_labels():
361361
plt.close()
362362

363363
# Override labels
364-
out = ct.gangof4_response(P1, C).plot(label='line1')
365-
out = ct.gangof4_response(P2, C).plot(label='line2')
364+
out = ct.gangof4_response(P1, C).plot(label='xxx, line1, yyy')
365+
out = ct.gangof4_response(P2, C).plot(label='xxx, line2, yyy')
366366
axs = ct.get_plot_axes(out)
367367
legend = axs[0, 1].get_legend().get_texts()
368-
assert legend[0].get_text() == 'line1'
369-
assert legend[1].get_text() == 'line2'
368+
assert legend[0].get_text() == 'xxx, line1, yyy'
369+
assert legend[1].get_text() == 'xxx, line2, yyy'
370370
plt.close()
371371

372372

control/timeplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ def _make_legend_labels(labels, ignore_common=False):
808808
suffix_len -= 1
809809

810810
# Strip the labels of common information
811-
if suffix_len > 0:
811+
if suffix_len > 0 and not ignore_common:
812812
labels = [label[prefix_len:-suffix_len] for label in labels]
813813
else:
814814
labels = [label[prefix_len:] for label in labels]

0 commit comments

Comments
 (0)