Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f48e59c

Browse files
authored
Merge pull request #16953 from CSCD01-team31/iss-16482
Changed 'colors' paramater in PyPlot vlines/hlines and Axes vlines/hlines to default to configured rcParams 'lines.color' option
2 parents 7021730 + fafa132 commit f48e59c

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

doc/api/api_changes_3.3/behaviour.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ explicitly pass a "%1.2f" as the *valfmt* parameter to `.Slider`.
181181

182182
Add *normalize* keyword argument to ``Axes.pie``
183183
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
184-
``pie()`` used to draw a partial pie if the sum of the values was < 1. This behavior
185-
is deprecated and will change to always normalizing the values to a full pie by default.
184+
``pie()`` used to draw a partial pie if the sum of the values was < 1. This behavior
185+
is deprecated and will change to always normalizing the values to a full pie by default.
186186
If you want to draw a partial pie, please pass ``normalize=False`` explicitly.
187187

188188
``table.CustomCell`` is now an alias for `.table.Cell`
@@ -307,3 +307,8 @@ but will become True in a later release.
307307
... to determine whether a string should be passed to the usetex machinery or
308308
not. This allows single strings to be marked as not-usetex even when the
309309
rcParam is True.
310+
311+
`.Axes.vlines`, `.Axes.hlines`, `.pyplot.vlines` and `.pyplot.hlines` *colors* parameter default change
312+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313+
314+
The *colors* parameter will now default to :rc:`lines.color`, while previously it defaulted to 'k'.

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
11161116

11171117
@_preprocess_data(replace_names=["y", "xmin", "xmax", "colors"],
11181118
label_namer="y")
1119-
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
1119+
def hlines(self, y, xmin, xmax, colors=None, linestyles='solid',
11201120
label='', **kwargs):
11211121
"""
11221122
Plot horizontal lines at each *y* from *xmin* to *xmax*.
@@ -1130,7 +1130,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
11301130
Respective beginning and end of each line. If scalars are
11311131
provided, all lines will have same length.
11321132
1133-
colors : list of colors, default: 'k'
1133+
colors : list of colors, default: :rc:`lines.color`
11341134
11351135
linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional
11361136
@@ -1196,7 +1196,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
11961196

11971197
@_preprocess_data(replace_names=["x", "ymin", "ymax", "colors"],
11981198
label_namer="x")
1199-
def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
1199+
def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
12001200
label='', **kwargs):
12011201
"""
12021202
Plot vertical lines.
@@ -1212,7 +1212,7 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
12121212
Respective beginning and end of each line. If scalars are
12131213
provided, all lines will have same length.
12141214
1215-
colors : list of colors, default: 'k'
1215+
colors : list of colors, default: :rc:`lines.color`
12161216
12171217
linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional
12181218

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,7 +2601,7 @@ def hist2d(
26012601
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
26022602
@_copy_docstring_and_deprecators(Axes.hlines)
26032603
def hlines(
2604-
y, xmin, xmax, colors='k', linestyles='solid', label='', *,
2604+
y, xmin, xmax, colors=None, linestyles='solid', label='', *,
26052605
data=None, **kwargs):
26062606
return gca().hlines(
26072607
y, xmin, xmax, colors=colors, linestyles=linestyles,
@@ -2972,7 +2972,7 @@ def violinplot(
29722972
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
29732973
@_copy_docstring_and_deprecators(Axes.vlines)
29742974
def vlines(
2975-
x, ymin, ymax, colors='k', linestyles='solid', label='', *,
2975+
x, ymin, ymax, colors=None, linestyles='solid', label='', *,
29762976
data=None, **kwargs):
29772977
return gca().vlines(
29782978
x, ymin, ymax, colors=colors, linestyles=linestyles,

lib/matplotlib/tests/test_axes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,13 @@ def test_vlines():
38153815
ax5.set_xlim(0, 15)
38163816

38173817

3818+
def test_vlines_default():
3819+
fig, ax = plt.subplots()
3820+
with mpl.rc_context({'lines.color': 'red'}):
3821+
lines = ax.vlines(0.5, 0, 1)
3822+
assert mpl.colors.same_color(lines.get_color(), 'red')
3823+
3824+
38183825
@image_comparison(['hlines_basic', 'hlines_with_nan', 'hlines_masked'],
38193826
extensions=['png'])
38203827
def test_hlines():
@@ -3855,6 +3862,13 @@ def test_hlines():
38553862
ax5.set_ylim(0, 15)
38563863

38573864

3865+
def test_hlines_default():
3866+
fig, ax = plt.subplots()
3867+
with mpl.rc_context({'lines.color': 'red'}):
3868+
lines = ax.hlines(0.5, 0, 1)
3869+
assert mpl.colors.same_color(lines.get_color(), 'red')
3870+
3871+
38583872
@pytest.mark.parametrize('data', [[1, 2, 3, np.nan, 5],
38593873
np.ma.masked_equal([1, 2, 3, 4, 5], 4)])
38603874
@check_figures_equal(extensions=["png"])

0 commit comments

Comments
 (0)