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

Skip to content

Changed 'colors' parameter in PyPlot vlines/hlines and Axes vlines/hlines to default to configured rcParams 'lines.color' option #16953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions doc/api/api_changes_3.3/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ explicitly pass a "%1.2f" as the *valfmt* parameter to `.Slider`.

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

``table.CustomCell`` is now an alias for `.table.Cell`
Expand Down Expand Up @@ -307,3 +307,8 @@ but will become True in a later release.
... to determine whether a string should be passed to the usetex machinery or
not. This allows single strings to be marked as not-usetex even when the
rcParam is True.

`.Axes.vlines`, `.Axes.hlines`, `.pyplot.vlines` and `.pyplot.hlines` *colors* parameter default change
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The *colors* parameter will now default to :rc:`lines.color`, while previously it defaulted to 'k'.
8 changes: 4 additions & 4 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):

@_preprocess_data(replace_names=["y", "xmin", "xmax", "colors"],
label_namer="y")
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
def hlines(self, y, xmin, xmax, colors=None, linestyles='solid',
label='', **kwargs):
"""
Plot horizontal lines at each *y* from *xmin* to *xmax*.
Expand All @@ -1130,7 +1130,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
Respective beginning and end of each line. If scalars are
provided, all lines will have same length.

colors : list of colors, default: 'k'
colors : list of colors, default: :rc:`lines.color`

linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional

Expand Down Expand Up @@ -1196,7 +1196,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',

@_preprocess_data(replace_names=["x", "ymin", "ymax", "colors"],
label_namer="x")
def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
label='', **kwargs):
"""
Plot vertical lines.
Expand All @@ -1212,7 +1212,7 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
Respective beginning and end of each line. If scalars are
provided, all lines will have same length.

colors : list of colors, default: 'k'
colors : list of colors, default: :rc:`lines.color`

linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2601,7 +2601,7 @@ def hist2d(
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.hlines)
def hlines(
y, xmin, xmax, colors='k', linestyles='solid', label='', *,
y, xmin, xmax, colors=None, linestyles='solid', label='', *,
data=None, **kwargs):
return gca().hlines(
y, xmin, xmax, colors=colors, linestyles=linestyles,
Expand Down Expand Up @@ -2972,7 +2972,7 @@ def violinplot(
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.vlines)
def vlines(
x, ymin, ymax, colors='k', linestyles='solid', label='', *,
x, ymin, ymax, colors=None, linestyles='solid', label='', *,
data=None, **kwargs):
return gca().vlines(
x, ymin, ymax, colors=colors, linestyles=linestyles,
Expand Down
14 changes: 14 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3815,6 +3815,13 @@ def test_vlines():
ax5.set_xlim(0, 15)


def test_vlines_default():
fig, ax = plt.subplots()
with mpl.rc_context({'lines.color': 'red'}):
lines = ax.vlines(0.5, 0, 1)
assert mpl.colors.same_color(lines.get_color(), 'red')


@image_comparison(['hlines_basic', 'hlines_with_nan', 'hlines_masked'],
extensions=['png'])
def test_hlines():
Expand Down Expand Up @@ -3855,6 +3862,13 @@ def test_hlines():
ax5.set_ylim(0, 15)


def test_hlines_default():
fig, ax = plt.subplots()
with mpl.rc_context({'lines.color': 'red'}):
lines = ax.hlines(0.5, 0, 1)
assert mpl.colors.same_color(lines.get_color(), 'red')


@pytest.mark.parametrize('data', [[1, 2, 3, np.nan, 5],
np.ma.masked_equal([1, 2, 3, 4, 5], 4)])
@check_figures_equal(extensions=["png"])
Expand Down