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

Skip to content

Commit d39c5b8

Browse files
committed
Renamed [xmin, ymin, xmax, ymax] in Bbox to [x0, y0, x1, y1] and
provide functions that really do give xmax etc. as well. Renamed lbrt to extents and lbwh to bounds (for consistency). Removed some dead code. svn path=/branches/transforms/; revision=3997
1 parent 939a992 commit d39c5b8

15 files changed

Lines changed: 182 additions & 195 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def __init__(self, fig, rect,
480480
if isinstance(rect, mtransforms.Bbox):
481481
self._position = rect
482482
else:
483-
self._position = mtransforms.Bbox.from_lbwh(*rect)
483+
self._position = mtransforms.Bbox.from_bounds(*rect)
484484
self._originalPosition = self._position.frozen()
485485
self.set_axes(self)
486486
self.set_aspect('auto')
@@ -1696,7 +1696,7 @@ def set_ylim(self, ymin=None, ymax=None, emit=True, **kwargs):
16961696
# Call all of the other y-axes that are shared with this one
16971697
for other in self._shared_y_axes.get_siblings(self):
16981698
if other is not self:
1699-
other.set_ylim(self.viewLim.ymin, self.viewLim.ymax, emit=False)
1699+
other.set_ylim(self.viewLim.intervaly, emit=False)
17001700

17011701
if self.figure.canvas is not None:
17021702
self.figure.canvas.draw_idle()
@@ -1902,7 +1902,6 @@ def format_deltas(key, dx, dy):
19021902
if self.get_aspect() != 'auto':
19031903
dx = 0.5 * (dx + dy)
19041904
dy = dx
1905-
xmin, ymin, xmax, ymax = p.lim.lbrt
19061905

19071906
alpha = npy.power(10.0, (dx, dy))
19081907
start = p.trans_inverse.transform_point((p.x, p.y))
@@ -5207,7 +5206,7 @@ def update_params(self):
52075206
figBottom = top - (rowNum+1)*figH - rowNum*sepH
52085207
figLeft = left + colNum*(figW + sepW)
52095208

5210-
self.figbox = mtransforms.Bbox.from_lbwh(figLeft, figBottom, figW, figH)
5209+
self.figbox = mtransforms.Bbox.from_bounds(figLeft, figBottom, figW, figH)
52115210
self.rowNum = rowNum
52125211
self.colNum = colNum
52135212
self.numRows = rows

lib/matplotlib/axis.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,16 +1070,15 @@ def _update_label_position(self, bboxes, bboxes2):
10701070
bottom = self.axes.bbox.ymin
10711071
else:
10721072
bbox = Bbox.union(bboxes)
1073-
bottom = bbox.ymin
1073+
bottom = bbox.y0
10741074
self.label.set_position( (x, bottom - self.LABELPAD*self.figure.dpi / 72.0))
10751075

10761076
else:
10771077
if not len(bboxes2):
10781078
top = self.axes.bbox.ymax
10791079
else:
10801080
bbox = bbox_union(bboxes2)
1081-
top = bbox.ymax
1082-
1081+
top = bbox.y1
10831082
self.label.set_position( (x, top+self.LABELPAD*self.figure.dpi / 72.0))
10841083

10851084
def _update_offset_text_position(self, bboxes, bboxes2):
@@ -1092,7 +1091,7 @@ def _update_offset_text_position(self, bboxes, bboxes2):
10921091
bottom = self.axes.bbox.ymin
10931092
else:
10941093
bbox = Bbox.union(bboxes)
1095-
bottom = bbox.ymin
1094+
bottom = bbox.y0
10961095
self.offsetText.set_position((x, bottom-self.OFFSETTEXTPAD*self.figure.dpi/72.0))
10971096

10981097
def set_ticks_position(self, position):
@@ -1280,9 +1279,8 @@ def _update_label_position(self, bboxes, bboxes2):
12801279
if not len(bboxes):
12811280
left = self.axes.bbox.xmin
12821281
else:
1283-
12841282
bbox = Bbox.union(bboxes)
1285-
left = bbox.xmin
1283+
left = bbox.x0
12861284

12871285
self.label.set_position( (left-self.LABELPAD*self.figure.dpi/72.0, y))
12881286

@@ -1291,7 +1289,7 @@ def _update_label_position(self, bboxes, bboxes2):
12911289
right = self.axes.bbox.xmax
12921290
else:
12931291
bbox = Bbox.union(bboxes2)
1294-
right = bbox.xmax
1292+
right = bbox.x1
12951293

12961294
self.label.set_position( (right+self.LABELPAD*self.figure.dpi/72.0, y))
12971295

lib/matplotlib/backend_bases.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ def release_zoom(self, event):
14221422
self.draw()
14231423
return
14241424

1425-
xmin, ymin, xmax, ymax = lim.lbrt
1425+
x0, y0, x1, y1 = lim.extents
14261426

14271427
# zoom to rect
14281428
inverse = a.transData.inverted()
@@ -1432,49 +1432,49 @@ def release_zoom(self, event):
14321432
Ymin,Ymax=a.get_ylim()
14331433

14341434
if Xmin < Xmax:
1435-
if x<lastx: xmin, xmax = x, lastx
1436-
else: xmin, xmax = lastx, x
1437-
if xmin < Xmin: xmin=Xmin
1438-
if xmax > Xmax: xmax=Xmax
1435+
if x<lastx: x0, x1 = x, lastx
1436+
else: x0, x1 = lastx, x
1437+
if x0 < Xmin: x0=Xmin
1438+
if x1 > Xmax: x1=Xmax
14391439
else:
1440-
if x>lastx: xmin, xmax = x, lastx
1441-
else: xmin, xmax = lastx, x
1442-
if xmin > Xmin: xmin=Xmin
1443-
if xmax < Xmax: xmax=Xmax
1440+
if x>lastx: x0, x1 = x, lastx
1441+
else: x0, x1 = lastx, x
1442+
if x0 > Xmin: x0=Xmin
1443+
if x1 < Xmax: x1=Xmax
14441444

14451445
if Ymin < Ymax:
1446-
if y<lasty: ymin, ymax = y, lasty
1447-
else: ymin, ymax = lasty, y
1448-
if ymin < Ymin: ymin=Ymin
1449-
if ymax > Ymax: ymax=Ymax
1446+
if y<lasty: y0, y1 = y, lasty
1447+
else: y0, y1 = lasty, y
1448+
if y0 < Ymin: y0=Ymin
1449+
if y1 > Ymax: y1=Ymax
14501450
else:
1451-
if y>lasty: ymin, ymax = y, lasty
1452-
else: ymin, ymax = lasty, y
1453-
if ymin > Ymin: ymin=Ymin
1454-
if ymax < Ymax: ymax=Ymax
1451+
if y>lasty: y0, y1 = y, lasty
1452+
else: y0, y1 = lasty, y
1453+
if y0 > Ymin: y0=Ymin
1454+
if y1 < Ymax: y1=Ymax
14551455

14561456
if self._button_pressed == 1:
1457-
a.set_xlim((xmin, xmax))
1458-
a.set_ylim((ymin, ymax))
1457+
a.set_xlim((x0, x1))
1458+
a.set_ylim((y0, y1))
14591459
elif self._button_pressed == 3:
14601460
if a.get_xscale()=='log':
1461-
alpha=npy.log(Xmax/Xmin)/npy.log(xmax/xmin)
1462-
x1=pow(Xmin/xmin,alpha)*Xmin
1463-
x2=pow(Xmax/xmin,alpha)*Xmin
1461+
alpha=npy.log(Xmax/Xmin)/npy.log(x1/x0)
1462+
rx1=pow(Xmin/x0,alpha)*Xmin
1463+
x2=pow(Xmax/x0,alpha)*Xmin
14641464
else:
1465-
alpha=(Xmax-Xmin)/(xmax-xmin)
1466-
x1=alpha*(Xmin-xmin)+Xmin
1467-
x2=alpha*(Xmax-xmin)+Xmin
1465+
alpha=(Xmax-Xmin)/(x1-x0)
1466+
rx1=alpha*(Xmin-x0)+Xmin
1467+
x2=alpha*(Xmax-x0)+Xmin
14681468
if a.get_yscale()=='log':
1469-
alpha=npy.log(Ymax/Ymin)/npy.log(ymax/ymin)
1470-
y1=pow(Ymin/ymin,alpha)*Ymin
1471-
y2=pow(Ymax/ymin,alpha)*Ymin
1469+
alpha=npy.log(Ymax/Ymin)/npy.log(y1/y0)
1470+
ry1=pow(Ymin/y0,alpha)*Ymin
1471+
ry2=pow(Ymax/y0,alpha)*Ymin
14721472
else:
1473-
alpha=(Ymax-Ymin)/(ymax-ymin)
1474-
y1=alpha*(Ymin-ymin)+Ymin
1475-
y2=alpha*(Ymax-ymin)+Ymin
1476-
a.set_xlim((x1, x2))
1477-
a.set_ylim((y1, y2))
1473+
alpha=(Ymax-Ymin)/(y1-y0)
1474+
ry1=alpha*(Ymin-y0)+Ymin
1475+
ry2=alpha*(Ymax-y0)+Ymin
1476+
a.set_xlim((rx1, rx2))
1477+
a.set_ylim((ry1, ry2))
14781478

14791479
self.draw()
14801480
self._xypress = None

lib/matplotlib/backends/backend_agg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(self, width, height, dpi):
118118
self.mathtext_parser = MathTextParser('Agg')
119119
self._fontd = {}
120120

121-
self.bbox = Bbox.from_lbwh(0,0, self.width, self.height)
121+
self.bbox = Bbox.from_bounds(0, 0, self.width, self.height)
122122
if __debug__: verbose.report('RendererAgg.__init__ done',
123123
'debug-annoying')
124124

@@ -227,7 +227,7 @@ def func(x):
227227

228228
cliprect = gc.get_clip_rectangle()
229229
if cliprect is None: bbox = None
230-
else: bbox = Bbox.from_lbwh(*cliprect)
230+
else: bbox = Bbox.from_bounds(*cliprect)
231231
self.draw_image(x, self.height-y, im, bbox)
232232

233233
def get_canvas_width_height(self):

lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,12 +1032,12 @@ def markerObject(self, path, trans, fillp, lw):
10321032
def writeMarkers(self):
10331033
for tup in self.markers.values():
10341034
name, object, path, trans, fillp, lw = tup
1035-
bbox = Bbox.from_lbrt(*path.get_extents(trans))
1035+
bbox = Bbox.from_extents(*path.get_extents(trans))
10361036
bbox = bbox.padded(lw * 0.5)
10371037
self.beginStream(
10381038
object.id, None,
10391039
{'Type': Name('XObject'), 'Subtype': Name('Form'),
1040-
'BBox': list(bbox.lbrt) })
1040+
'BBox': list(bbox.extents) })
10411041
self.writePath(path, trans)
10421042
if fillp:
10431043
self.output(Op.fill_stroke)

lib/matplotlib/collections.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ def get_transforms(self):
126126
return self._transforms
127127

128128
def get_datalim(self, transData):
129-
result = transforms.Bbox.from_lbrt(*path.get_path_collection_extents(
130-
self.get_transform().frozen(),
131-
self.get_paths(),
132-
self.get_transforms(),
133-
self._offsets,
134-
self._transOffset.frozen()))
129+
result = path.get_path_collection_extents(
130+
self.get_transform().frozen(),
131+
self.get_paths(),
132+
self.get_transforms(),
133+
self._offsets,
134+
self._transOffset.frozen())
135135
result = result.transformed(transData.inverted())
136136
return result
137137

lib/matplotlib/figure.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def __init__(self,
131131

132132
self._dpi_scale_trans = Affine2D()
133133
self.dpi = dpi
134-
self.bbox_inches = Bbox.from_lbwh(0, 0, *figsize)
134+
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
135135
self.bbox = TransformedBbox(self.bbox_inches, self._dpi_scale_trans)
136136

137137
self.frameon = frameon
@@ -351,11 +351,11 @@ def get_facecolor(self):
351351

352352
def get_figwidth(self):
353353
'Return the figwidth as a float'
354-
return self.bbox_inches.xmax
354+
return self.bbox_inches.width
355355

356356
def get_figheight(self):
357357
'Return the figheight as a float'
358-
return self.bbox_inches.ymax
358+
return self.bbox_inches.height
359359

360360
def get_dpi(self):
361361
'Return the dpi as a float'
@@ -395,15 +395,15 @@ def set_figwidth(self, val):
395395
396396
ACCEPTS: float
397397
"""
398-
self.bbox_inches.xmax = val
398+
self.bbox_inches.x1 = val
399399

400400
def set_figheight(self, val):
401401
"""
402402
Set the height of the figure in inches
403403
404404
ACCEPTS: float
405405
"""
406-
self.bbox_inches.ymax = val
406+
self.bbox_inches.y1 = val
407407

408408
def set_frameon(self, b):
409409
"""

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def make_image(self, magnification=1.0):
156156
im.apply_translation(-1, -1)
157157

158158
# the viewport translation
159-
tx = (xmin-self.axes.viewLim.xmin)/dxintv * numcols
160-
ty = (ymin-self.axes.viewLim.ymin)/dyintv * numrows
159+
tx = (xmin-self.axes.viewLim.x0)/dxintv * numcols
160+
ty = (ymin-self.axes.viewLim.y0)/dyintv * numrows
161161

162162
l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
163163
widthDisplay *= magnification

lib/matplotlib/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def _find_best_position(self, width, height, consider=None):
442442

443443
candidates = []
444444
for l, b in consider:
445-
legendBox = Bbox.from_lbwh(l, b, width, height)
445+
legendBox = Bbox.from_bounds(l, b, width, height)
446446
badness = 0
447447
badness = legendBox.count_contains(verts)
448448
badness += legendBox.count_overlaps(bboxes)

lib/matplotlib/lines.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -673,39 +673,6 @@ def _draw_solid(self, renderer, gc, path, trans):
673673
gc.set_linestyle('solid')
674674
renderer.draw_path(gc, path, trans)
675675

676-
677-
def _step(self, x, y, where):
678-
if not cbook.iterable(x):
679-
x = ma.array([x], dtype=npy.float_)
680-
if not cbook.iterable(y):
681-
y = ma.array([y], dtype=npy.float_)
682-
683-
if where=='pre':
684-
x2 = ma.zeros((2*len(x)-1,), npy.float_)
685-
y2 = ma.zeros((2*len(y)-1,), npy.float_)
686-
687-
x2[0::2], x2[1::2] = x, x[:-1]
688-
y2[0::2], y2[1:-1:2] = y, y[1:]
689-
690-
elif where=='post':
691-
x2 = ma.zeros((2*len(x)-1,), npy.float_)
692-
y2 = ma.zeros((2*len(y)-1,), npy.float_)
693-
694-
x2[::2], x2[1:-1:2] = x, x[1:]
695-
y2[0::2], y2[1::2] = y, y[:-1]
696-
697-
elif where=='mid':
698-
x2 = ma.zeros((2*len(x),), npy.float_)
699-
y2 = ma.zeros((2*len(y),), npy.float_)
700-
701-
x2[1:-1:2] = 0.5*(x[:-1]+x[1:])
702-
x2[2::2] = 0.5*(x[:-1]+x[1:])
703-
x2[0], x2[-1] = x[0], x[-1]
704-
705-
y2[0::2], y2[1::2] = y, y
706-
707-
return x2, y2
708-
709676

710677
def _draw_steps_pre(self, renderer, gc, path, trans):
711678
vertices = self._xy

0 commit comments

Comments
 (0)