Skip to content

Commit 8f8f525

Browse files
committed
Allow passing label to plots
1 parent 41ef9a8 commit 8f8f525

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Added
1414

1515
- A logotype.
1616
- A label will automatically be added to all ``freq*``-plots that will show up when
17-
using a legend. These are "Magnitude", "Phase", and "Group delay".
17+
using a legend. These are "Magnitude", "Phase", and "Group delay". If you pass a label,
18+
this will not happen.
1819
- ``style='twin'`` now plots lines with different colors from the color cycle to
1920
distinguish the two lines. The same holds for :func:`mplsignal.scipyplot.freqz_twin`,
2021
which also adds a legend.

lib/mplsignal/freq_plots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def _mag_plot_z(
394394
magnitude = 20 * np.log10(np.abs(h))
395395
wscale = _get_freq_scale(freq_unit, fs)
396396
w = wscale * w
397-
ax.plot(w, magnitude, label="Magnitude", **kwargs)
397+
ax.plot(w, magnitude, label=kwargs.pop("label", "Magnitude"), **kwargs)
398398

399399
if xlabel is not None:
400400
ax.set_xlabel(xlabel)
@@ -441,7 +441,7 @@ def _phase_plot_z(
441441
phase = 180 / np.pi * phase
442442
wscale = _get_freq_scale(freq_unit, fs)
443443
w = wscale * w
444-
ax.plot(w, phase, label="Phase", **kwargs)
444+
ax.plot(w, phase, label=kwargs.pop("label", "Phase"), **kwargs)
445445

446446
if xlabel is not None:
447447
ax.set_xlabel(xlabel)
@@ -488,7 +488,7 @@ def _group_delay_plot_z(
488488
wscale = _get_freq_scale(freq_unit, fs)
489489
w = wscale * w
490490

491-
ax.plot(w, gd, label="Group delay", **kwargs)
491+
ax.plot(w, gd, label=kwargs.pop("label", "Group delay"), **kwargs)
492492

493493
if xlabel is not None:
494494
ax.set_xlabel(xlabel)

0 commit comments

Comments
 (0)