From 55320d3d339de0996afa8e7dc51a663c7d842153 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:17:33 +0100 Subject: [PATCH] Discourage alternate strings for 'none' linestyle Inspired by but independent of the discussion around the representation of linestyles #29304. For other linestyles we have a short visual representation (e.g. "--") and a name (dashed "dashed"). No linestyle currently has four accepted writings "", " ", "none", "None". This PR recommends only to use "" (visual representation) and "none" (named representation). It discourages " " and "None". This should guide users towards more canonical usage. We may later decide whether to deprecate the alternatives. Note also, that we have not used the alternatives in examples. --- lib/matplotlib/inset.py | 18 +++++++++--------- lib/matplotlib/lines.py | 18 +++++++++--------- lib/matplotlib/patches.py | 18 +++++++++--------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/matplotlib/inset.py b/lib/matplotlib/inset.py index bab69491303e..0aa54439e3a5 100644 --- a/lib/matplotlib/inset.py +++ b/lib/matplotlib/inset.py @@ -119,15 +119,15 @@ def set_linestyle(self, ls): """ Set the linestyle of the rectangle and the connectors. - ========================================== ================= - linestyle description - ========================================== ================= - ``'-'`` or ``'solid'`` solid line - ``'--'`` or ``'dashed'`` dashed line - ``'-.'`` or ``'dashdot'`` dash-dotted line - ``':'`` or ``'dotted'`` dotted line - ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing - ========================================== ================= + ======================================================= ================ + linestyle description + ======================================================= ================ + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + ``''`` or ``'none'`` (discouraged: ``'None'``, ``' '``) draw nothing + ======================================================= ================ Alternatively a dash tuple of the following form can be provided:: diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 65a4ccb6d950..2330403532a5 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -1152,15 +1152,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'``, ``'None'``, ``' '``, or ``''`` draw nothing - ========================================== ================= + ======================================================= ================ + linestyle description + ======================================================= ================ + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + ``''`` or ``'none'`` (discouraged: ``'None'``, ``' '``) 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 f47c8abee32d..3b9f4a259105 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -445,15 +445,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'``, ``'None'``, ``' '``, or ``''`` draw nothing - ========================================== ================= + ======================================================= ================ + linestyle description + ======================================================= ================ + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + ``''`` or ``'none'`` (discouraged: ``'None'``, ``' '``) draw nothing + ======================================================= ================ Alternatively a dash tuple of the following form can be provided::