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

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Additionally checked for the case when the desired vmax or vmin are o…
…utside 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.
  • Loading branch information
kthyng committed Jun 28, 2013
commit d806c1a803f62c261dbfdc41c2b1da80bdc9f7b6
17 changes: 12 additions & 5 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import matplotlib.patches as mpatches
import matplotlib.texmanager as texmanager
import matplotlib.transforms as mtrans
import pdb

# Import needed for adding manual selection capability to clabel
from matplotlib.blocking_input import BlockingContourLabeler
Expand Down Expand Up @@ -1196,7 +1197,7 @@ def _process_levels(self):
# want to leave the original levels attribute unchanged.
# (Colorbar needs this even for line contours.)
self._levels = list(self.levels)

pdb.set_trace()
if self.extend in ('both', 'min'):
self._levels.insert(0, min(self.levels[0], self.zmin) - 1)
if self.extend in ('both', 'max'):
Expand Down Expand Up @@ -1495,18 +1496,24 @@ def _contour_args(self, args, kwargs):
(fn, fn))

# Check for vmin and vmax values and max out z values accordingly
# want zmax and zmin to be able to be outside data range, according to input vmin/vmax
if 'vmax' in kwargs:
vmax = kwargs.pop('vmax')
vmax = kwargs['vmax']
ind = z > vmax
z[ind] = vmax
self.zmax = kwargs.pop('vmax')
else:
self.zmax = ma.maximum(z)
if 'vmin' in kwargs:
vmin = kwargs.pop('vmin')
vmin = kwargs['vmin']
ind = z < vmin
z[ind] = vmin
self.zmin = kwargs.pop('vmin')
else:
self.zmin = ma.minimum(z)

z = ma.masked_invalid(z, copy=False)
self.zmax = ma.maximum(z)
self.zmin = ma.minimum(z)

if self.logscale and self.zmin <= 0:
z = ma.masked_where(z <= 0, z)
warnings.warn('Log scale: values of z <= 0 have been masked')
Expand Down