8000 changed 'colors' parameter to default to rcParams['lines.color'] in l… · CSCD01-team31/matplotlib@fe3405f · GitHub
[go: up one dir, main page]

Skip to content

Commit fe3405f

Browse files
committed
changed 'colors' parameter to default to rcParams['lines.color'] in line with issue matplotlib#16482
1 parent d1f07d3 commit fe3405f

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

lib/matplotlib/axes/_axes.py

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

11031103
@_preprocess_data(replace_names=["y", "xmin", "xmax", "colors"],
11041104
label_namer="y")
1105-
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
1106-
label='', **kwargs):
1105+
def hlines(self, y, xmin, xmax, colors=rcParams['lines.color'] or 'k',
1106+
linestyles='solid', label='', **kwargs):
11071107
"""
11081108
Plot horizontal lines at each *y* from *xmin* to *xmax*.
11091109
@@ -1182,8 +1182,8 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
11821182

11831183
@_preprocess_data(replace_names=["x", "ymin", "ymax", "colors"],
11841184
label_namer="x")
1185-
def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
1186-
label='', **kwargs):
1185+
def vlines(self, x, ymin, ymax, colors=rcParams['lines.color'] or 'k',
1186+
linestyles='solid', label='', **kwargs):
11871187
"""
11881188
Plot vertical lines.
11891189

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,8 +2533,8 @@ def hist2d(
25332533
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
25342534
@_copy_docstring_and_deprecators(Axes.hlines)
25352535
def hlines(
2536-
y, xmin, xmax, colors='k', linestyles='solid', label='', *,
2537-
data=None, **kwargs):
2536+
y, xmin, xmax, colors=rcParams['lines.color'] or 'k',
2537+
linestyles='solid', label='', *, data=None, **kwargs):
25382538
return gca().hlines(
25392539
y, xmin, xmax, colors=colors, linestyles=linestyles,
25402540
label=label, **({"data": data} if data is not None else {}),
@@ -2904,8 +2904,8 @@ def violinplot(
29042904
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
29052905
@_copy_docstring_and_deprecators(Axes.vlines)
29062906
def vlines(
2907-
x, ymin, ymax, colors='k', linestyles='solid', label='', *,
2908-
data=None, **kwargs):
2907+
x, ymin, ymax, colors=rcParams['lines.color'] or 'k',
2908+
linestyles='solid', label='', *, data=None, **kwargs):
29092909
return gca().vlines(
29102910
x, ymin, ymax, colors=colors, linestyles=linestyles,
29112911
label=label, **({"data": data} if data is not None else {}),

lib/matplotlib/tests/test_axes.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,7 +3963,7 @@ def test_axline_args():
39633963
ax.axline((0, 0), slope=1)
39643964

39653965

3966-
@image_comparison(['vlines_basic', 'vlines_with_nan', 'vlines_masked'],
3966+
@image_comparison(['vlines_basic', 'vlines_with_nan', 'vlines_masked', 'vlines_rc_params'],
39673967
extensions=['png'])
39683968 8000
def test_vlines():
39693969
# normal
@@ -4002,8 +4002,14 @@ def test_vlines():
40024002
ax5.vlines(x5, ymin5, ymax5, colors='k', linewidth=2)
40034003
ax5.set_xlim(0, 15)
40044004

4005+
# check that vlines() correctly defaults to rcParams['lines.color']
4006+
fig4, ax6 = plt.subplots()
4007+
with mpl.rc_context({'lines.color': 'blue'}):
4008+
ax6.vlines(0.5, 0, 1)
4009+
ax6.hlines(0.5, 0, 1, colors='k')
40054010

4006-
@image_comparison(['hlines_basic', 'hlines_with_nan', 'hlines_masked'],
4011+
4012+
@image_comparison(['hlines_basic', 'hlines_with_nan', 'hlines_masked', 'hlines_rc_params'],
40074013
extensions=['png'])
40084014
def test_hlines():
40094015
# normal
@@ -4042,6 +4048,12 @@ def test_hlines():
40424048
ax5.hlines(y5, xmin5, xmax5, colors='k', linewidth=2)
40434049
ax5.set_ylim(0, 15)
40444050

4051+
# check that hlines() correctly defaults to rcParams['lines.color']
4052+
fig4, ax6 = plt.subplots()
4053+
with mpl.rc_context({'lines.color': 'blue'}):
4054+
ax6.hlines(0.5, 0, 1)
4055+
ax6.vlines(0.5, 0, 1, colors='k')
4056+
40454057

40464058
@pytest.mark.parametrize('data', [[1, 2, 3, np.nan, 5],
40474059
np.ma.masked_equal([1, 2, 3, 4, 5], 4)])

0 commit comments

Comments
 (0)
0