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

Skip to content

Commit efe110b

Browse files
committed
Contourf: change method of making bottom bound include zmin.
This avoids a problem in colorbar tick labeling when zmin is 0. svn path=/trunk/matplotlib/; revision=8093
1 parent 4a68406 commit efe110b

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

lib/matplotlib/contour.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,17 @@ def __init__(self, ax, *args, **kwargs):
676676
if self.filled:
677677
if self.linewidths is not None:
678678
warnings.warn('linewidths is ignored by contourf')
679+
679680
lowers = self._levels[:-1]
681+
if self.zmin == lowers[0]:
682+
# Include minimum values in lowest interval
683+
lowers = lowers.copy() # so we don't change self._levels
684+
if self.logscale:
685+
lowers[0] = 0.99 * self.zmin
686+
else:
687+
lowers[0] -= 1
680688
uppers = self._levels[1:]
689+
681690
for level, level_upper in zip(lowers, uppers):
682691
nlist = C.trace(level, level_upper, nchunk = self.nchunk)
683692
nseg = len(nlist)//2
@@ -756,14 +765,6 @@ def _autolev(self, z, N):
756765
zmin = self.zmin
757766
self.locator.set_bounds(zmin, zmax)
758767
lev = self.locator()
759-
zmargin = (zmax - zmin) * 0.000001 # so z < (zmax + zmargin)
760-
if zmax >= lev[-1]:
761-
lev[-1] += zmargin
762-
if zmin <= lev[0]:
763-
if self.logscale:
764-
lev[0] = 0.99 * zmin
765-
else:
766-
lev[0] -= zmargin
767768
self._auto = True
768769
if self.filled:
769770
return lev
@@ -1141,6 +1142,15 @@ def set_alpha(self, alpha):
11411142
be removed. Chunking introduces artifacts at the chunk boundaries
11421143
unless *antialiased* is *False*.
11431144
1145+
Note: contourf fills intervals that are closed at the top; that
1146+
is, for boundaries *z1* and *z2*, the filled region is::
1147+
1148+
z1 < z <= z2
1149+
1150+
There is one exception: if the lowest boundary coincides with
1151+
the minimum value of the *z* array, then that minimum value
1152+
will be included in the lowest interval.
1153+
11441154
**Examples:**
11451155
11461156
.. plot:: mpl_examples/pylab_examples/contour_demo.py

0 commit comments

Comments
 (0)