Skip to content

Commit bf46fec

Browse files
Contour kwarg for negative_linestyles
1 parent 1b2a3c9 commit bf46fec

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

lib/matplotlib/contour.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,10 @@ class ContourSet(cm.ScalarMappable, ContourLabeler):
721721

722722
def __init__(self, ax, *args,
723723
levels=None, filled=False, linewidths=None, linestyles=None,
724-
hatches=(None,), alpha=None, origin=None, extent=None,
725-
cmap=None, colors=None, norm=None, vmin=None, vmax=None,
726-
extend='neither', antialiased=None, nchunk=0, locator=None,
727-
transform=None,
724+
negative_linestyles=None, hatches=(None,), alpha=None,
725+
origin=None, extent=None, cmap=None, colors=None, norm=None,
726+
vmin=None, vmax=None, extend='neither', antialiased=None,
727+
nchunk=0, locator=None, transform=None,
728728
**kwargs):
729729
"""
730730
Draw contour lines or filled regions, depending on
@@ -775,6 +775,7 @@ def __init__(self, ax, *args,
775775
self.filled = filled
776776
self.linewidths = linewidths
777777
self.linestyles = linestyles
778+
self.negative_linestyles = negative_linestyles
778779
self.hatches = hatches
779780
self.alpha = alpha
780781
self.origin = origin
@@ -1296,10 +1297,14 @@ def _process_linewidths(self):
12961297
def _process_linestyles(self):
12971298
linestyles = self.linestyles
12981299
Nlev = len(self.levels)
1300+
neg_ls = self.negative_linestyles
12991301
if linestyles is None:
13001302
tlinestyles = ['solid'] * Nlev
13011303
if self.monochrome:
1302-
neg_ls = mpl.rcParams['contour.negative_linestyle']
1304+
# If negative_linestyles was not defined as a kwarg,
1305+
# define negative_linestyles with rcParams
1306+
if not neg_ls:
1307+
neg_ls = mpl.rcParams['contour.negative_linestyle']
13031308
eps = - (self.zmax - self.zmin) * 1e-15
13041309
for i, lev in enumerate(self.levels):
13051310
if lev < eps:
@@ -1764,6 +1769,18 @@ def _initialize_x_y(self, z):
17641769
iterable is shorter than the number of contour levels
17651770
it will be repeated as necessary.
17661771
1772+
negative_linestyles : *None* or str, optional
1773+
{'solid', 'dashed', 'dashdot', 'dotted'}
1774+
*Only applies to* `.contour`.
1775+
1776+
If *negative_linestyles* is *None*, the default is 'dashed' for
1777+
negative contours.
1778+
1779+
*negative_linestyles* can also be an iterable of the above
1780+
strings specifying a set of linestyles to be used. If this
1781+
iterable is shorter than the number of contour levels
1782+
it will be repeated as necessary.
1783+
17671784
hatches : list[str], optional
17681785
*Only applies to* `.contourf`.
17691786

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy