diff --git a/doc/api/api_changes_3.3/behaviour.rst b/doc/api/api_changes_3.3/behaviour.rst index d8a9e377b4d9..40b1bb3d79d8 100644 --- a/doc/api/api_changes_3.3/behaviour.rst +++ b/doc/api/api_changes_3.3/behaviour.rst @@ -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` @@ -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'. diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 286bf4b87566..c43c3e133ab5 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -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*. @@ -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 @@ -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. @@ -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 diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 32f63db834c1..24b26e49cf75 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -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, @@ -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, diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 3efee619c8f3..c8563b159f5b 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -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(): @@ -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"])