From dedc592d0a76386419d08cf4ff9bcf5d15519119 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sat, 11 Sep 2021 20:31:11 +0200 Subject: [PATCH] Backport PR #21041: Prefer "none" to "None" in docs, examples and comments. --- examples/axes_grid1/inset_locator_demo.py | 6 +++--- .../marker_reference.py | 2 +- .../shapes_and_collections/compound_path.py | 2 +- examples/statistics/errorbars_and_boxes.py | 4 ++-- lib/matplotlib/axes/_axes.py | 3 +-- lib/matplotlib/axes/_base.py | 2 +- lib/matplotlib/lines.py | 18 ++++++++-------- lib/matplotlib/patches.py | 21 ++++++++----------- lib/mpl_toolkits/mplot3d/axes3d.py | 3 +-- 9 files changed, 28 insertions(+), 33 deletions(-) diff --git a/examples/axes_grid1/inset_locator_demo.py b/examples/axes_grid1/inset_locator_demo.py index 16e3cab5f964..974783c04309 100644 --- a/examples/axes_grid1/inset_locator_demo.py +++ b/examples/axes_grid1/inset_locator_demo.py @@ -69,7 +69,7 @@ bbox_transform=ax.transAxes, loc=3) # For visualization purposes we mark the bounding box by a rectangle -ax.add_patch(plt.Rectangle((.2, .4), .6, .5, ls="--", ec="c", fc="None", +ax.add_patch(plt.Rectangle((.2, .4), .6, .5, ls="--", ec="c", fc="none", transform=ax.transAxes)) # We set the axis limits to something other than the default, in order to not @@ -89,9 +89,9 @@ bbox_transform=ax3.transAxes) # For visualization purposes we mark the bounding box by a rectangle -ax2.add_patch(plt.Rectangle((0, 0), 1, 1, ls="--", lw=2, ec="c", fc="None")) +ax2.add_patch(plt.Rectangle((0, 0), 1, 1, ls="--", lw=2, ec="c", fc="none")) ax3.add_patch(plt.Rectangle((.7, .5), .3, .5, ls="--", lw=2, - ec="c", fc="None")) + ec="c", fc="none")) # Turn ticklabels off for axi in [axins2, axins3, ax2, ax3]: diff --git a/examples/lines_bars_and_markers/marker_reference.py b/examples/lines_bars_and_markers/marker_reference.py index 450906637c01..98af2519124c 100644 --- a/examples/lines_bars_and_markers/marker_reference.py +++ b/examples/lines_bars_and_markers/marker_reference.py @@ -117,7 +117,7 @@ def split_list(a_list): fig.suptitle('Mathtext markers', fontsize=14) fig.subplots_adjust(left=0.4) -marker_style.update(markeredgecolor="None", markersize=15) +marker_style.update(markeredgecolor="none", markersize=15) markers = ["$1$", r"$\frac{1}{2}$", "$f$", "$\u266B$", r"$\mathcal{A}$"] for y, marker in enumerate(markers): diff --git a/examples/shapes_and_collections/compound_path.py b/examples/shapes_and_collections/compound_path.py index 76a11703ab9b..d721eaf1c392 100644 --- a/examples/shapes_and_collections/compound_path.py +++ b/examples/shapes_and_collections/compound_path.py @@ -23,7 +23,7 @@ path = Path(vertices, codes) -pathpatch = PathPatch(path, facecolor='None', edgecolor='green') +pathpatch = PathPatch(path, facecolor='none', edgecolor='green') fig, ax = plt.subplots() ax.add_patch(pathpatch) diff --git a/examples/statistics/errorbars_and_boxes.py b/examples/statistics/errorbars_and_boxes.py index ac0d7cb6cd66..a8bdd7a46384 100644 --- a/examples/statistics/errorbars_and_boxes.py +++ b/examples/statistics/errorbars_and_boxes.py @@ -40,7 +40,7 @@ def make_error_boxes(ax, xdata, ydata, xerror, yerror, facecolor='r', - edgecolor='None', alpha=0.5): + edgecolor='none', alpha=0.5): # Loop over data points; create box from errors at each point errorboxes = [Rectangle((x - xe[0], y - ye[0]), xe.sum(), ye.sum()) @@ -55,7 +55,7 @@ def make_error_boxes(ax, xdata, ydata, xerror, yerror, facecolor='r', # Plot errorbars artists = ax.errorbar(xdata, ydata, xerr=xerror, yerr=yerror, - fmt='None', ecolor='k') + fmt='none', ecolor='k') return artists diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 257ae2fe4839..cef0f8c3c88d 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3317,8 +3317,7 @@ def errorbar(self, x, y, yerr=None, xerr=None, %(Line2D:kwdoc)s """ kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D) - # anything that comes in as 'None', drop so the default thing - # happens down stream + # Drop anything that comes in as None to use the default instead. kwargs = {k: v for k, v in kwargs.items() if v is not None} kwargs.setdefault('zorder', 2) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index bcac6bbbf331..97ed781b00f6 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -1291,7 +1291,7 @@ def cla(self): self.patch = self._gen_axes_patch() self.patch.set_figure(self.figure) self.patch.set_facecolor(self._facecolor) - self.patch.set_edgecolor('None') + self.patch.set_edgecolor('none') self.patch.set_linewidth(0) self.patch.set_transform(self.transAxes) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index e3bfced3cf21..b4614868b784 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -1093,15 +1093,15 @@ def set_linestyle(self, ls): - A string: - =============================== ================= - Linestyle Description - =============================== ================= - ``'-'`` or ``'solid'`` solid line - ``'--'`` or ``'dashed'`` dashed line - ``'-.'`` or ``'dashdot'`` dash-dotted line - ``':'`` or ``'dotted'`` dotted line - ``'None'`` or ``' '`` or ``''`` draw nothing - =============================== ================= + ========================================== ================= + linestyle description + ========================================== ================= + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing + ========================================== ================= - Alternatively a dash tuple of the following form can be provided:: diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index fa54b6f613fd..253e8abe2ef7 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -419,18 +419,15 @@ def set_linestyle(self, ls): """ Set the patch linestyle. - =========================== ================= - linestyle description - =========================== ================= - ``'-'`` or ``'solid'`` solid line - ``'--'`` or ``'dashed'`` dashed line - ``'-.'`` or ``'dashdot'`` dash-dotted line - ``':'`` or ``'dotted'`` dotted line - ``'None'`` draw nothing - ``'none'`` draw nothing - ``' '`` draw nothing - ``''`` draw nothing - =========================== ================= + ========================================== ================= + linestyle description + ========================================== ================= + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing + ========================================== ================= Alternatively a dash tuple of the following form can be provided:: diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index d4eef7ca77e6..a738c4a38a5f 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -3033,8 +3033,7 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='', had_data = self.has_data() kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D) - # anything that comes in as 'None', drop so the default thing - # happens down stream + # Drop anything that comes in as None to use the default instead. kwargs = {k: v for k, v in kwargs.items() if v is not None} kwargs.setdefault('zorder', 2)