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

Skip to content

Commit d806c1a

Browse files
committed
Additionally checked for the case when the desired vmax or vmin are outside the range of the data. In this case, the contour plot, if extend for the appropriate direction is also chosen, will appropriately reflect the desired range.
1 parent f8eacb6 commit d806c1a

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

lib/matplotlib/contour.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import matplotlib.patches as mpatches
2222
import matplotlib.texmanager as texmanager
2323
import matplotlib.transforms as mtrans
24+
import pdb
2425

2526
# Import needed for adding manual selection capability to clabel
2627
from matplotlib.blocking_input import BlockingContourLabeler
@@ -1196,7 +1197,7 @@ def _process_levels(self):
11961197
# want to leave the original levels attribute unchanged.
11971198
# (Colorbar needs this even for line contours.)
11981199
self._levels = list(self.levels)
1199-
1200+
pdb.set_trace()
12001201
if self.extend in ('both', 'min'):
12011202
self._levels.insert(0, min(self.levels[0], self.zmin) - 1)
12021203
if self.extend in ('both', 'max'):
@@ -1495,18 +1496,24 @@ def _contour_args(self, args, kwargs):
14951496
(fn, fn))
14961497

14971498
# Check for vmin and vmax values and max out z values accordingly
1499+
# want zmax and zmin to be able to be outside data range, according to input vmin/vmax
14981500
if 'vmax' in kwargs:
1499-
vmax = kwargs.pop('vmax')
1501+
vmax = kwargs['vmax']
15001502
ind = z > vmax
15011503
z[ind] = vmax
1504+
self.zmax = kwargs.pop('vmax')
1505+
else:
1506+
self.zmax = ma.maximum(z)
15021507
if 'vmin' in kwargs:
1503-
vmin = kwargs.pop('vmin')
1508+
vmin = kwargs['vmin']
15041509
ind = z < vmin
15051510
z[ind] = vmin
1511+
self.zmin = kwargs.pop('vmin')
1512+
else:
1513+
self.zmin = ma.minimum(z)
15061514

15071515
z = ma.masked_invalid(z, copy=False)
1508-
self.zmax = ma.maximum(z)
1509-
self.zmin = ma.minimum(z)
1516+
15101517
if self.logscale and self.zmin <= 0:
15111518
z = ma.masked_where(z <= 0, z)
15121519
warnings.warn('Log scale: values of z <= 0 have been masked')

0 commit comments

Comments
 (0)