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

Skip to content

Commit c721cf0

Browse files
committed
Merge branch 'v1.1.x'
Conflicts: lib/matplotlib/__init__.py
2 parents 561d0da + cbb11da commit c721cf0

File tree

6 files changed

+42
-23
lines changed

6 files changed

+42
-23
lines changed

doc/users/recipes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Transparent, fancy legends
307307
==========================
308308

309309
Sometimes you know what your data looks like before you plot it, and
310-
mak know for instance that there won't be much data in the upper right
310+
may know for instance that there won't be much data in the upper right
311311
hand corner. Then you can safely create a legend that doesn't overlay
312312
your data::
313313

@@ -316,7 +316,7 @@ your data::
316316
Other times you don't know where your data is, and loc='best' will try
317317
and place the legend::
318318

319-
ax.legend(loc='upper right')
319+
ax.legend(loc='best')
320320

321321
but still, your legend may overlap your data, and in these cases it's
322322
nice to make the legend frame transparent.

lib/matplotlib/backends/backend_gdk.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def draw_image(self, gc, x, y, im):
141141
def draw_text(self, gc, x, y, s, prop, angle, ismath):
142142
x, y = int(x), int(y)
143143

144-
if x <0 or y <0: # window has shrunk and text is off the edge
144+
if x < 0 or y < 0: # window has shrunk and text is off the edge
145145
return
146146

147147
if angle not in (0,90):
@@ -156,6 +156,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
156156
else:
157157
layout, inkRect, logicalRect = self._get_pango_layout(s, prop)
158158
l, b, w, h = inkRect
159+
if (x + w > self.width or y + h > self.height):
160+
return
161+
159162
self.gdkDrawable.draw_layout(gc.gdkGC, x, y-h-b, layout)
160163

161164

@@ -224,7 +227,8 @@ def _draw_rotated_text(self, gc, x, y, s, prop, angle):
224227
x = int(x-h)
225228
y = int(y-w)
226229

227-
if x < 0 or y < 0: # window has shrunk and text is off the edge
230+
if (x < 0 or y < 0 or # window has shrunk and text is off the edge
231+
x + w > self.width or y + h > self.height):
228232
return
229233

230234
key = (x,y,s,angle,hash(prop))

lib/matplotlib/backends/qt4_editor/formlayout.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ def setup(self):
273273
elif isinstance(value, (str, unicode)):
274274
field = QLineEdit(value, self)
275275
elif isinstance(value, (list, tuple)):
276-
selindex = list(value).pop(0)
276+
if isinstance(value, tuple):
277+
value = list(value)
278+
selindex = value.pop(0)
277279
field = QComboBox(self)
278280
if isinstance(value[0], (list, tuple)):
279281
keys = [ key for key, _val in value ]

lib/matplotlib/tests/test_mlab.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ def test_recarray_csv_roundtrip():
3030

3131
@raises(ValueError)
3232
def test_rec2csv_bad_shape():
33-
bad = np.recarray((99,4),[('x',np.float),('y',np.float)])
34-
fd = tempfile.TemporaryFile(suffix='csv')
35-
36-
# the bad recarray should trigger a ValueError for having ndim > 1.
37-
mlab.rec2csv(bad,fd)
33+
try:
34+
bad = np.recarray((99,4),[('x',np.float),('y',np.float)])
35+
fd = tempfile.TemporaryFile(suffix='csv')
36+
37+
# the bad recarray should trigger a ValueError for having ndim > 1.
38+
mlab.rec2csv(bad,fd)
39+
finally:
40+
fd.close()
3841

3942
def test_prctile():
4043
# test odd lengths

lib/matplotlib/ticker.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,15 +1549,22 @@ def __call__(self):
15491549
try:
15501550
majorstep = majorlocs[1] - majorlocs[0]
15511551
except IndexError:
1552-
raise ValueError('Need at least two major ticks to find minor '
1553-
'tick locations')
1552+
# Need at least two major ticks to find minor tick locations
1553+
# TODO: Figure out a way to still be able to display minor
1554+
# ticks without two major ticks visible. For now, just display
1555+
# no ticks at all.
1556+
majorstep = 0
15541557

15551558
if self.ndivs is None:
1556-
x = int(round(10 ** (np.log10(majorstep) % 1)))
1557-
if x in [1, 5, 10]:
1558-
ndivs = 5
1559-
else:
1560-
ndivs = 4
1559+
if majorstep == 0 :
1560+
# TODO: Need a better way to figure out ndivs
1561+
ndivs = 1
1562+
else :
1563+
x = int(round(10 ** (np.log10(majorstep) % 1)))
1564+
if x in [1, 5, 10]:
1565+
ndivs = 5
1566+
else:
1567+
ndivs = 4
15611568
else:
15621569
ndivs = self.ndivs
15631570

@@ -1567,12 +1574,15 @@ def __call__(self):
15671574
if vmin > vmax:
15681575
vmin,vmax = vmax,vmin
15691576

1570-
t0 = majorlocs[0]
1571-
tmin = np.ceil((vmin - t0) / minorstep) * minorstep
1572-
tmax = np.floor((vmax - t0) / minorstep) * minorstep
1573-
locs = np.arange(tmin, tmax, minorstep) + t0
1574-
cond = np.abs((locs - t0) % majorstep) > minorstep/10.0
1575-
locs = locs.compress(cond)
1577+
if len(majorlocs) > 0:
1578+
t0 = majorlocs[0]
1579+
tmin = np.ceil((vmin - t0) / minorstep) * minorstep
1580+
tmax = np.floor((vmax - t0) / minorstep) * minorstep
1581+
locs = np.arange(tmin, tmax, minorstep) + t0
1582+
cond = np.abs((locs - t0) % majorstep) > minorstep/10.0
1583+
locs = locs.compress(cond)
1584+
else:
1585+
locs = []
15761586

15771587
return self.raise_if_exceeds(np.array(locs))
15781588

0 commit comments

Comments
 (0)