|
From: <md...@us...> - 2007-09-10 17:39:47
|
Revision: 3822
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3822&view=rev
Author: mdboom
Date: 2007-09-10 10:39:37 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
Baby steps and horrible breakage on transforms branch.
Modified Paths:
--------------
branches/transforms/lib/matplotlib/artist.py
branches/transforms/lib/matplotlib/axes.py
branches/transforms/lib/matplotlib/axis.py
branches/transforms/lib/matplotlib/backends/backend_agg.py
branches/transforms/lib/matplotlib/figure.py
branches/transforms/lib/matplotlib/legend.py
branches/transforms/lib/matplotlib/lines.py
branches/transforms/lib/matplotlib/pylab.py
branches/transforms/lib/matplotlib/table.py
branches/transforms/lib/matplotlib/text.py
branches/transforms/lib/matplotlib/transforms.py
branches/transforms/lib/matplotlib/widgets.py
Modified: branches/transforms/lib/matplotlib/artist.py
===================================================================
--- branches/transforms/lib/matplotlib/artist.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/artist.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -1,7 +1,7 @@
from __future__ import division
import sys, re
from cbook import iterable, flatten
-from transforms import identity_transform
+from affine import Affine2D
import matplotlib.units as units
## Note, matplotlib artists use the doc strings for set and get
@@ -145,7 +145,7 @@
def get_transform(self):
'return the Transformation instance used by this artist'
if self._transform is None:
- self._transform = identity_transform()
+ self._transform = Affine2D()
return self._transform
def hitlist(self,event):
Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/axes.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -9,6 +9,8 @@
rcParams = matplotlib.rcParams
from matplotlib import artist as martist
+from matplotlib import affine as maffine
+from matplotlib import bbox as mbbox
from matplotlib import agg
from matplotlib import axis as maxis
from matplotlib import cbook
@@ -23,11 +25,11 @@
from matplotlib import mlab
from matplotlib import cm
from matplotlib import patches as mpatches
+from matplotlib import pbox as mpbox
from matplotlib import quiver as mquiver
from matplotlib import table as mtable
from matplotlib import text as mtext
from matplotlib import ticker as mticker
-from matplotlib import transforms as mtrans
iterable = cbook.iterable
is_string_like = cbook.is_string_like
@@ -413,14 +415,7 @@
yield seg
remaining=remaining[2:]
-ValueType=type(mtrans.zero())
-def makeValue(v):
- if type(v) == ValueType:
- return v
- else:
- return mtrans.Value(v)
-
class Axes(martist.Artist):
"""
The Axes contains most of the figure elements: Axis, Tick, Line2D,
@@ -434,10 +429,15 @@
"""
- scaled = {mtrans.IDENTITY : 'linear',
- mtrans.LOG10 : 'log',
+ # MGDTODO
+# scaled = {mtrans.IDENTITY : 'linear',
+# mtrans.LOG10 : 'log',
+# }
+ scaled = {0 : 'linear',
+ 1 : 'log',
}
+
def __str__(self):
return "Axes(%g,%g;%gx%g)"%(self._position[0].get(),self._position[1].get(),
self._position[2].get(),self._position[3].get())
@@ -485,7 +485,7 @@
"""
martist.Artist.__init__(self)
- self._position = map(makeValue, rect)
+ self._position = rect
self._originalPosition = rect
self.set_axes(self)
self.set_aspect('auto')
@@ -629,12 +629,9 @@
self.right = (l+w)*figw
self.top = (b+h)*figh
-
- Bbox = mtrans.Bbox
- Point = mtrans.Point
- self.bbox = Bbox(
- Point(self.left, self.bottom),
- Point(self.right, self.top ),
+ self.bbox = mbbox.Bbox.from_lbrt(
+ self.left, self.bottom,
+ self.right, self.top,
)
#these will be updated later as data is added
self._set_lim_and_transforms()
@@ -644,40 +641,36 @@
set the dataLim and viewLim BBox attributes and the
transData and transAxes Transformation attributes
"""
-
-
- one = mtrans.one
- zero = mtrans.zero
- Point = mtrans.Point
- Bbox = mtrans.Bbox
+ Bbox = mbbox.Bbox
if self._sharex is not None:
- left=self._sharex.viewLim.ll().x()
- right=self._sharex.viewLim.ur().x()
+ left = self._sharex.viewLim.xmin()
+ right = self._sharex.viewLim.xmax()
else:
- left=zero()
- right=one()
+ left = 0.0
+ right = 1.0
if self._sharey is not None:
- bottom=self._sharey.viewLim.ll().y()
- top=self._sharey.viewLim.ur().y()
+ bottom = self._sharey.viewLim.ymin()
+ top = self._sharey.viewLim.ymax()
else:
- bottom=zero()
- top=one()
+ bottom = 0.0
+ top = 1.0
- self.viewLim = Bbox(Point(left, bottom), Point(right, top))
- self.dataLim = mtrans.unit_bbox()
+ self.viewLim = Bbox.from_lbrt(left, bottom, right, top)
+ self.dataLim = Bbox.unit()
- self.transData = mtrans.get_bbox_transform(
+ self.transData = maffine.get_bbox_transform(
self.viewLim, self.bbox)
- self.transAxes = mtrans.get_bbox_transform(
- mtrans.unit_bbox(), self.bbox)
+ self.transAxes = maffine.get_bbox_transform(
+ Bbox.unit(), self.bbox)
- if self._sharex:
- self.transData.set_funcx(self._sharex.transData.get_funcx())
+ # MGDTODO
+# if self._sharex:
+# self.transData.set_funcx(self._sharex.transData.get_funcx())
- if self._sharey:
- self.transData.set_funcy(self._sharey.transData.get_funcy())
+# if self._sharey:
+# self.transData.set_funcy(self._sharey.transData.get_funcy())
def get_position(self, original=False):
'Return the axes rectangle left, bottom, width, height'
@@ -861,7 +854,7 @@
"""
ACCEPTS: ['C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W']
"""
- if anchor in mtrans.PBox.coefs.keys() or len(anchor) == 2:
+ if anchor in mpbox.PBox.coefs.keys() or len(anchor) == 2:
self._anchor = anchor
else:
raise ValueError('argument must be among %s' %
@@ -901,7 +894,7 @@
if data_ratio is None:
data_ratio = ysize/xsize
box_aspect = A * data_ratio
- pb = mtrans.PBox(self._originalPosition)
+ pb = mpbox.PBox(self._originalPosition)
pb1 = pb.shrink_to_aspect(box_aspect, fig_aspect)
self.set_position(pb1.anchor(self._anchor), 'active')
return
@@ -1538,11 +1531,12 @@
if xmin is None: xmin = old_xmin
if xmax is None: xmax = old_xmax
- if (self.transData.get_funcx().get_type()==mtrans.LOG10
- and min(xmin, xmax)<=0):
- raise ValueError('Cannot set nonpositive limits with log transform')
+ # MGDTODO
+# if (self.transData.get_funcx().get_type()==mtrans.LOG10
+# and min(xmin, xmax)<=0):
+# raise ValueError('Cannot set nonpositive limits with log transform')
- xmin, xmax = mtrans.nonsingular(xmin, xmax, increasing=False)
+ xmin, xmax = mbbox.nonsingular(xmin, xmax, increasing=False)
self.viewLim.intervalx().set_bounds(xmin, xmax)
if emit: self.callbacks.process('xlim_changed', self)
@@ -1574,19 +1568,22 @@
#if subsx is None: subsx = range(2, basex)
assert(value.lower() in ('log', 'linear', ))
if value == 'log':
- self.xaxis.set_major_locator(mticker.LogLocator(basex))
- self.xaxis.set_major_formatter(mticker.LogFormatterMathtext(basex))
- self.xaxis.set_minor_locator(mticker.LogLocator(basex,subsx))
- self.transData.get_funcx().set_type(mtrans.LOG10)
- minx, maxx = self.get_xlim()
- if min(minx, maxx)<=0:
- self.autoscale_view()
+ # MGDTODO
+# self.xaxis.set_major_locator(mticker.LogLocator(basex))
+# self.xaxis.set_major_formatter(mticker.LogFormatterMathtext(basex))
+# self.xaxis.set_minor_locator(mticker.LogLocator(basex,subsx))
+# self.transData.get_funcx().set_type(mtrans.LOG10)
+# minx, maxx = self.get_xlim()
+# if min(minx, maxx)<=0:
+# self.autoscale_view()
+ pass
elif value == 'linear':
self.xaxis.set_major_locator(mticker.AutoLocator())
self.xaxis.set_major_formatter(mticker.ScalarFormatter())
self.xaxis.set_minor_locator(mticker.NullLocator())
self.xaxis.set_minor_formatter(mticker.NullFormatter())
- self.transData.get_funcx().set_type( mtrans.IDENTITY )
+ # self.transData.get_funcx().set_type( mtrans.IDENTITY )
+ self.transData.get_funcx().set_type( 0 ) # MGDTODO
def get_xticks(self):
'Return the x ticks as a list of locations'
@@ -1659,11 +1656,12 @@
if ymin is None: ymin = old_ymin
if ymax is None: ymax = old_ymax
- if (self.transData.get_funcy().get_type()==mtrans.LOG10
- and min(ymin, ymax)<=0):
- raise ValueError('Cannot set nonpositive limits with log transform')
+ # MGDTODO
+# if (self.transData.get_funcy().get_type()==mtrans.LOG10
+# and min(ymin, ymax)<=0):
+# raise ValueError('Cannot set nonpositive limits with log transform')
- ymin, ymax = mtrans.nonsingular(ymin, ymax, increasing=False)
+ ymin, ymax = mbbox.nonsingular(ymin, ymax, increasing=False)
self.viewLim.intervaly().set_bounds(ymin, ymax)
if emit: self.callbacks.process('ylim_changed', self)
@@ -1696,21 +1694,24 @@
assert(value.lower() in ('log', 'linear', ))
if value == 'log':
- self.yaxis.set_major_locator(mticker.LogLocator(basey))
- self.yaxis.set_major_formatter(mticker.LogFormatterMathtext(basey))
- self.yaxis.set_minor_locator(mticker.LogLocator(basey,subsy))
- self.transData.get_funcy().set_type(mtrans.LOG10)
- miny, maxy = self.get_ylim()
- if min(miny, maxy)<=0:
- self.autoscale_view()
-
+ # MGDTODO
+# self.yaxis.set_major_locator(mticker.LogLocator(basey))
+# self.yaxis.set_major_formatter(mticker.LogFormatterMathtext(basey))
+# self.yaxis.set_minor_locator(mticker.LogLocator(basey,subsy))
+# self.transData.get_funcy().set_type(mtrans.LOG10)
+# miny, maxy = self.get_ylim()
+# if min(miny, maxy)<=0:
+# self.autoscale_view()
+ pass
+
elif value == 'linear':
self.yaxis.set_major_locator(mticker.AutoLocator())
self.yaxis.set_major_formatter(mticker.ScalarFormatter())
self.yaxis.set_minor_locator(mticker.NullLocator())
self.yaxis.set_minor_formatter(mticker.NullFormatter())
- self.transData.get_funcy().set_type( mtrans.IDENTITY )
-
+ # self.transData.get_funcy().set_type( mtrans.IDENTITY ) MGDTODO
+ self.transData.get_funcy().set_type( 0 )
+
def get_yticks(self):
'Return the y ticks as a list of locations'
return self.yaxis.get_ticklocs()
@@ -1744,9 +1745,11 @@
def toggle_log_lineary(self):
'toggle between log and linear on the y axis'
- funcy = self.transData.get_funcy().get_type()
- if funcy==mtrans.LOG10: self.set_yscale('linear')
- elif funcy==mtrans.IDENTITY: self.set_yscale('log')
+ # MGDTODO
+# funcy = self.transData.get_funcy().get_type()
+# if funcy==mtrans.LOG10: self.set_yscale('linear')
+# elif funcy==mtrans.IDENTITY: self.set_yscale('log')
+ pass
def xaxis_date(self, tz=None):
"""Sets up x-axis ticks and labels that treat the x data as dates.
@@ -2172,7 +2175,7 @@
%(Annotation)s
"""
a = mtext.Annotation(*args, **kwargs)
- a.set_transform(mtrans.identity_transform())
+ a.set_transform(maffine.Affine2D.identity())
self._set_artist_props(a)
if kwargs.has_key('clip_on'): a.set_clip_box(self.bbox)
self.texts.append(a)
@@ -2211,7 +2214,7 @@
%(Line2D)s
"""
- trans = mtrans.blend_xy_sep_transform( self.transAxes, self.transData)
+ trans = maffine.blend_xy_sep_transform( self.transAxes, self.transData)
l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False, **kwargs)
return l
@@ -2247,7 +2250,7 @@
%(Line2D)s
"""
- trans = mtrans.blend_xy_sep_transform( self.transData, self.transAxes )
+ trans = maffine.blend_xy_sep_transform( self.transData, self.transAxes )
l, = self.plot([x,x], [ymin,ymax] , transform=trans, scaley=False, **kwargs)
return l
@@ -2286,7 +2289,7 @@
%(Polygon)s
"""
# convert y axis units
- trans = mtrans.blend_xy_sep_transform( self.transAxes, self.transData)
+ trans = maffine.blend_xy_sep_transform( self.transAxes, self.transData)
verts = (xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)
p = mpatches.Polygon(verts, **kwargs)
p.set_transform(trans)
@@ -2326,7 +2329,7 @@
%(Polygon)s
"""
# convert x axis units
- trans = mtrans.blend_xy_sep_transform(self.transData, self.transAxes)
+ trans = maffine.blend_xy_sep_transform(self.transData, self.transAxes)
verts = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]
p = mpatches.Polygon(verts, **kwargs)
p.set_transform(trans)
@@ -4105,7 +4108,7 @@
offsets = zip(x,y),
transOffset = self.transData,
)
- collection.set_transform(mtrans.identity_transform())
+ collection.set_transform(maffine.Affine2D())
collection.set_alpha(alpha)
collection.update(kwargs)
@@ -5299,21 +5302,22 @@
# the lim are theta, r
- Bbox = mtrans.Bbox
- Value = mtrans.Value
- Point = mtrans.Point
- self.dataLim = Bbox( Point( Value(5/4.*math.pi), Value(math.sqrt(2))),
- Point( Value(1/4.*math.pi), Value(math.sqrt(2))))
- self.viewLim = Bbox( Point( Value(5/4.*math.pi), Value(math.sqrt(2))),
- Point( Value(1/4.*math.pi), Value(math.sqrt(2))))
+ # MGDTODO
+# Bbox = mtrans.Bbox
+# Value = mtrans.Value
+# Point = mtrans.Point
+# self.dataLim = Bbox( Point( Value(5/4.*math.pi), Value(math.sqrt(2))),
+# Point( Value(1/4.*math.pi), Value(math.sqrt(2))))
+# self.viewLim = Bbox( Point( Value(5/4.*math.pi), Value(math.sqrt(2))),
+# Point( Value(1/4.*math.pi), Value(math.sqrt(2))))
- self.transData = mtrans.NonseparableTransformation(
- self.viewLim, self.bbox,
- mtrans.FuncXY(mtrans.POLAR))
- self.transAxes = mtrans.get_bbox_transform(
- mtrans.unit_bbox(), self.bbox)
+# self.transData = mtrans.NonseparableTransformation(
+# self.viewLim, self.bbox,
+# mtrans.FuncXY(mtrans.POLAR))
+# self.transAxes = mtrans.get_bbox_transform(
+# mtrans.unit_bbox(), self.bbox)
+ pass
-
def contains(self,mouseevent):
"""Test whether the mouse event occured in the axes.
@@ -5380,6 +5384,7 @@
# we need to set a view and data interval from 0->rmax to make
# the formatter and locator work correctly
+ # MGDTODO
Value = mtrans.Value
Interval = mtrans.Interval
self.rintv = Interval(Value(0), Value(1))
Modified: branches/transforms/lib/matplotlib/axis.py
===================================================================
--- branches/transforms/lib/matplotlib/axis.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/axis.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -15,8 +15,8 @@
from ticker import NullFormatter, FixedFormatter, ScalarFormatter, LogFormatter
from ticker import NullLocator, FixedLocator, LinearLocator, LogLocator, AutoLocator
-from transforms import Value, blend_xy_sep_transform,\
- translation_transform, bbox_all, identity_transform
+from affine import Affine2D, blend_xy_sep_transform
+from bbox import bbox_union
from font_manager import FontProperties
from text import Text, TextWithDash, _process_text_args
from patches import bbox_artist
@@ -81,16 +81,16 @@
if self._tickdir == 'in':
self._xtickmarkers = (TICKUP, TICKDOWN)
self._ytickmarkers = (TICKRIGHT, TICKLEFT)
- self._pad = Value(pad)
+ self._pad = pad
else:
self._xtickmarkers = (TICKDOWN, TICKUP)
self._ytickmarkers = (TICKLEFT, TICKRIGHT)
- self._pad = Value(pad + size)
+ self._pad = pad + size
self._loc = loc
self._size = size
- self._padPixels = self.figure.dpi*self._pad*Value(1/72.0)
+ self._padPixels = self.figure.dpi * self._pad * (1/72.0)
self.tick1line = self._get_tick1line(loc)
@@ -236,14 +236,11 @@
xaxis=True,
)
-
- trans = blend_xy_sep_transform( self.axes.transData,
- self.axes.transAxes)
+ trans = blend_xy_sep_transform(
+ self.axes.transData, self.axes.transAxes)
#offset the text downward with a post transformation
- transOffset = translation_transform(
- Value(0), Value(-1)*self._padPixels)
- trans.set_offset( (0,0), transOffset)
- t.set_transform( trans)
+ trans = trans + Affine2D().translated(0, -1 * self._padPixels)
+ t.set_transform(trans)
self._set_artist_props(t)
return t
@@ -264,12 +261,10 @@
horizontalalignment='center',
)
- trans = blend_xy_sep_transform( self.axes.transData,
- self.axes.transAxes)
+ trans = blend_xy_sep_transformation(
+ self.axes.transData, self.axes.transAxes)
# offset the text upward with a post transformation
- transOffset = translation_transform(
- Value(0), self._padPixels)
- trans.set_offset( (0,0), transOffset)
+ trans = trans + Affine2D().translated(0, self._padPixels)
t.set_transform( trans )
self._set_artist_props(t)
return t
@@ -284,8 +279,8 @@
marker = self._xtickmarkers[0],
markersize=self._size,
)
- l.set_transform( blend_xy_sep_transform( self.axes.transData,
- self.axes.transAxes) )
+ l.set_transform(blend_xy_sep_transform(
+ self.axes.transData, self.axes.transAxes) )
self._set_artist_props(l)
return l
@@ -300,8 +295,8 @@
markersize=self._size,
)
- l.set_transform( blend_xy_sep_transform( self.axes.transData,
- self.axes.transAxes) )
+ l.set_transform(blend_xy_sep_transform(
+ self.axes.transData, self.axes.transAxes) )
self._set_artist_props(l)
return l
@@ -314,8 +309,9 @@
linewidth=rcParams['grid.linewidth'],
antialiased=False,
)
- l.set_transform( blend_xy_sep_transform( self.axes.transData,
- self.axes.transAxes) )
+ l.set_transform(
+ blend_xy_sep_transform(
+ self.axes.transData, self.axes.transAxes))
l.set_clip_box(self.axes.bbox)
self._set_artist_props(l)
@@ -363,13 +359,11 @@
dashdirection=0,
xaxis=False,
)
- trans = blend_xy_sep_transform( self.axes.transAxes,
- self.axes.transData)
+ trans = blend_xy_sep_transform(
+ self.axes.transAxes, self.axes.transData)
# offset the text leftward with a post transformation
+ trans = trans + Affine2D().translated(-1 * self._padPixels, 0)
- transOffset = translation_transform(
- Value(-1)*self._padPixels, Value(0))
- trans.set_offset( (0,0), transOffset)
t.set_transform( trans )
#t.set_transform( self.axes.transData )
self._set_artist_props(t)
@@ -388,13 +382,10 @@
xaxis=False,
horizontalalignment='left',
)
- trans = blend_xy_sep_transform( self.axes.transAxes,
- self.axes.transData)
+ trans = blend_xy_sep_transform(
+ self.axes.transAxes, self.axes.transData)
# offset the text rightward with a post transformation
-
- transOffset = translation_transform(
- self._padPixels, Value(0))
- trans.set_offset( (0,0), transOffset)
+ trans = trans + Affine2D().translated(self._padPixels, 0)
t.set_transform( trans )
self._set_artist_props(t)
return t
@@ -409,8 +400,9 @@
linestyle = 'None',
markersize=self._size,
)
- l.set_transform( blend_xy_sep_transform( self.axes.transAxes,
- self.axes.transData) )
+ l.set_transform(
+ blend_xy_sep_transform(
+ self.axes.transAxes, self.axes.transData))
self._set_artist_props(l)
return l
@@ -424,8 +416,9 @@
markersize=self._size,
)
- l.set_transform( blend_xy_sep_transform( self.axes.transAxes,
- self.axes.transData) )
+ l.set_transform(
+ blend_xy_sep_transform(
+ self.axes.transAxes, self.axes.transData))
self._set_artist_props(l)
return l
@@ -439,8 +432,8 @@
antialiased=False,
)
- l.set_transform( blend_xy_sep_transform( self.axes.transAxes,
- self.axes.transData) )
+ l.set_transform( blend_xy_sep_transform(
+ self.axes.transAxes, self.axes.transData) )
l.set_clip_box(self.axes.bbox)
self._set_artist_props(l)
@@ -989,8 +982,8 @@
verticalalignment='top',
horizontalalignment='center',
)
- label.set_transform( blend_xy_sep_transform( self.axes.transAxes,
- identity_transform() ))
+ label.set_transform( blend_xy_sep_transform(
+ self.axes.transAxes, Affine2D() ))
self._set_artist_props(label)
self.label_position='bottom'
@@ -1004,8 +997,8 @@
verticalalignment='top',
horizontalalignment='right',
)
- offsetText.set_transform( blend_xy_sep_transform( self.axes.transAxes,
- identity_transform() ))
+ offsetText.set_transform( blend_xy_sep_transform(
+ self.axes.transAxes, Affine2D() ))
self._set_artist_props(offsetText)
self.offset_text_position='bottom'
return offsetText
@@ -1041,7 +1034,7 @@
bottom = self.axes.bbox.ymin()
else:
- bbox = bbox_all(bboxes)
+ bbox = bbox_union(bboxes)
bottom = bbox.ymin()
self.label.set_position( (x, bottom-self.LABELPAD*self.figure.dpi.get()/72.0))
@@ -1051,7 +1044,7 @@
top = self.axes.bbox.ymax()
else:
- bbox = bbox_all(bboxes2)
+ bbox = bbox_union(bboxes2)
top = bbox.ymax()
self.label.set_position( (x, top+self.LABELPAD*self.figure.dpi.get()/72.0))
@@ -1065,7 +1058,7 @@
if not len(bboxes):
bottom = self.axes.bbox.ymin()
else:
- bbox = bbox_all(bboxes)
+ bbox = bbox_union(bboxes)
bottom = bbox.ymin()
self.offsetText.set_position((x, bottom-self.OFFSETTEXTPAD*self.figure.dpi.get()/72.0))
@@ -1179,8 +1172,8 @@
horizontalalignment='right',
rotation='vertical',
)
- label.set_transform( blend_xy_sep_transform( identity_transform(),
- self.axes.transAxes) )
+ label.set_transform( blend_xy_sep_transform(
+ Affine2D(), self.axes.transAxes) )
self._set_artist_props(label)
self.label_position='left'
@@ -1194,8 +1187,8 @@
verticalalignment = 'bottom',
horizontalalignment = 'left',
)
- offsetText.set_transform(blend_xy_sep_transform(self.axes.transAxes,
- identity_transform()) )
+ offsetText.set_transform(blend_xy_sep_transform(
+ self.axes.transAxes, Affine2D()) )
self._set_artist_props(offsetText)
self.offset_text_position='left'
return offsetText
@@ -1231,7 +1224,7 @@
left = self.axes.bbox.xmin()
else:
- bbox = bbox_all(bboxes)
+ bbox = bbox_union(bboxes)
left = bbox.xmin()
self.label.set_position( (left-self.LABELPAD*self.figure.dpi.get()/72.0, y))
@@ -1241,7 +1234,7 @@
right = self.axes.bbox.xmax()
else:
- bbox = bbox_all(bboxes2)
+ bbox = bbox_union(bboxes2)
right = bbox.xmax()
self.label.set_position( (right+self.LABELPAD*self.figure.dpi.get()/72.0, y))
Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -84,7 +84,7 @@
from matplotlib.font_manager import findfont
from matplotlib.ft2font import FT2Font, LOAD_DEFAULT
from matplotlib.mathtext import MathTextParser
-from matplotlib.transforms import lbwh_to_bbox
+from matplotlib.bbox import Bbox
from _backend_agg import RendererAgg as _RendererAgg
@@ -126,7 +126,7 @@
self.mathtext_parser = MathTextParser('Agg')
self._fontd = {}
- self.bbox = lbwh_to_bbox(0,0, self.width, self.height)
+ self.bbox = Bbox.from_lbwh(0,0, self.width, self.height)
if __debug__: verbose.report('RendererAgg.__init__ done',
'debug-annoying')
@@ -277,7 +277,7 @@
cliprect = gc.get_clip_rectangle()
if cliprect is None: bbox = None
- else: bbox = lbwh_to_bbox(*cliprect)
+ else: bbox = Bbox.from_lbwh(*cliprect)
self.draw_image(x, self.height-y, im, bbox)
def get_canvas_width_height(self):
Modified: branches/transforms/lib/matplotlib/figure.py
===================================================================
--- branches/transforms/lib/matplotlib/figure.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/figure.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -18,7 +18,8 @@
from text import Text, _process_text_args
from legend import Legend
-from transforms import Bbox, Value, Point, get_bbox_transform, unit_bbox
+from affine import get_bbox_transform
+from bbox import Bbox
from ticker import FormatStrFormatter
from cm import ScalarMappable
from contour import ContourSet
@@ -127,17 +128,14 @@
if facecolor is None: facecolor = rcParams['figure.facecolor']
if edgecolor is None: edgecolor = rcParams['figure.edgecolor']
- self.dpi = Value(dpi)
- self.figwidth = Value(figsize[0])
- self.figheight = Value(figsize[1])
- self.ll = Point( Value(0), Value(0) )
- self.ur = Point( self.figwidth*self.dpi,
- self.figheight*self.dpi )
- self.bbox = Bbox(self.ll, self.ur)
-
+ self.dpi = dpi
+ self.bbox = Bbox.from_lbwh(0, 0,
+ self.figsize[0] * dpi,
+ self.figsize[1] * dpi)
+
self.frameon = frameon
- self.transFigure = get_bbox_transform( unit_bbox(), self.bbox)
+ self.transFigure = get_bbox_transform( Bbox.unit(), self.bbox)
Modified: branches/transforms/lib/matplotlib/legend.py
===================================================================
--- branches/transforms/lib/matplotlib/legend.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/legend.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -34,12 +34,9 @@
from patches import Patch, Rectangle, RegularPolygon, Shadow, bbox_artist, draw_bbox
from collections import LineCollection, RegularPolyCollection, PatchCollection
from text import Text
-from transforms import Bbox, Point, Value, get_bbox_transform, bbox_all,\
- unit_bbox, inverse_transform_bbox, lbwh_to_bbox
+from affine import get_bbox_transform
+from bbox import Bbox, bbox_union
-
-
-
def line_cuts_bbox(line, bbox):
""" Return True if and only if line cuts bbox. """
minx, miny, width, height = bbox.get_bounds()
@@ -168,7 +165,7 @@
else:
raise TypeError("Legend needs either Axes or Figure as parent")
self.parent = parent
- self.set_transform( get_bbox_transform( unit_bbox(), parent.bbox) )
+ self.set_transform( get_bbox_transform( Bbox.unit(), parent.bbox) )
if loc is None:
loc = rcParams["legend.loc"]
@@ -263,10 +260,10 @@
bboxesAll = bboxesText
bboxesAll.extend(bboxesHandles)
- bbox = bbox_all(bboxesAll)
+ bbox = bbox_union(bboxesAll)
self.save = bbox
- ibox = inverse_transform_bbox(self.get_transform(), bbox)
+ ibox = bbox.inverse_transform(self.get_transform())
self.ibox = ibox
return ibox
@@ -468,7 +465,7 @@
candidates = []
for l, b in consider:
- legendBox = lbwh_to_bbox(l, b, width, height)
+ legendBox = Bbox.from_lbwh(l, b, width, height)
badness = 0
badness = legendBox.count_contains(verts)
ox, oy = l-tx, b-ty
Modified: branches/transforms/lib/matplotlib/lines.py
===================================================================
--- branches/transforms/lib/matplotlib/lines.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/lines.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -18,7 +18,7 @@
from cbook import iterable, is_string_like, is_numlike
from colors import colorConverter
-from transforms import lbwh_to_bbox, LOG10
+from bbox import lbwh_to_bbox
from matplotlib import rcParams
# special-purpose marker identifiers:
@@ -378,7 +378,7 @@
bottom -= ms/2
width += ms
height += ms
- return lbwh_to_bbox( left, bottom, width, height)
+ return lbwh_to_bbox(left, bottom, width, height)
def set_axes(self, ax):
@@ -447,13 +447,15 @@
x, y = self._x, self._y
- try: logx = self.get_transform().get_funcx().get_type()==LOG10
- except RuntimeError: logx = False # non-separable
+ # MGDTODO: Deal with the log scale here
+
+# try: logx = self.get_transform().get_funcx().get_type()==LOG10
+# except RuntimeError: logx = False # non-separable
- try: logy = self.get_transform().get_funcy().get_type()==LOG10
- except RuntimeError: logy = False # non-separable
+# try: logy = self.get_transform().get_funcy().get_type()==LOG10
+# except RuntimeError: logy = False # non-separable
- if not logx and not logy:
+ if True:
return x, y
if self._logcache is not None:
Modified: branches/transforms/lib/matplotlib/pylab.py
===================================================================
--- branches/transforms/lib/matplotlib/pylab.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/pylab.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -234,7 +234,6 @@
from lines import Line2D
from text import Text, Annotation
from patches import Polygon, Rectangle, Circle, Arrow
-from transforms import blend_xy_sep_transform
from widgets import SubplotTool, Button, Slider, Widget
import numerix as nx
Modified: branches/transforms/lib/matplotlib/table.py
===================================================================
--- branches/transforms/lib/matplotlib/table.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/table.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -29,12 +29,10 @@
from patches import Rectangle
from cbook import enumerate, is_string_like, flatten
from text import Text
-from transforms import Bbox, inverse_transform_bbox, bbox_all, unit_bbox, \
- get_bbox_transform
+from bbox import Bbox, bbox_union
-
class Cell(Rectangle):
"""
A cell is a Rectangle with some associated text.
@@ -132,7 +130,7 @@
def get_text_bounds(self, renderer):
""" Get text bounds in axes co-ordinates. """
bbox = self._text.get_window_extent(renderer)
- bboxa = inverse_transform_bbox(self.get_transform(), bbox)
+ bbox.inverse_transform(self.get_transform())
return bboxa.get_bounds()
def get_required_width(self, renderer):
Modified: branches/transforms/lib/matplotlib/text.py
===================================================================
--- branches/transforms/lib/matplotlib/text.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/text.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -15,7 +15,7 @@
from cbook import enumerate, is_string_like, maxdict, is_numlike
from font_manager import FontProperties
from patches import bbox_artist, YAArrow
-from transforms import lbwh_to_bbox, bbox_all, identity_transform
+from bbox import lbwh_to_bbox, bbox_union
from lines import Line2D
import matplotlib.nxutils as nxutils
Modified: branches/transforms/lib/matplotlib/transforms.py
===================================================================
--- branches/transforms/lib/matplotlib/transforms.py 2007-09-10 06:55:10 UTC (rev 3821)
+++ branches/transforms/lib/matplotlib/transforms.py 2007-09-10 17:39:37 UTC (rev 3822)
@@ -1,652 +1,652 @@
-"""
-The transforms module is broken into two parts, a collection of
-classes written in the extension module _transforms to handle
-efficient transformation of data, and some helper functions in
-transforms to make it easy to instantiate and use those objects.
-Hence the core of this module lives in _transforms.
+# """
+# The transforms module is broken into two parts, a collection of
+# classes written in the extension module _transforms to handle
+# efficient transformation of data, and some helper functions in
+# transforms to make it easy to instantiate and use those objects.
+# Hence the core of this module lives in _transforms.
-The transforms class is built around the idea of a LazyValue. A
-LazyValue is a base class that defines a method get that returns the
-value. The concrete derived class Value wraps a float, and simply
-returns the value of that float. The concrete derived class BinOp
-allows binary operations on LazyValues, so you can add them, multiply
-them, etc. When you do something like
+# The transforms class is built around the idea of a LazyValue. A
+# LazyValue is a base class that defines a method get that returns the
+# value. The concrete derived class Value wraps a float, and simply
+# returns the value of that float. The concrete derived class BinOp
+# allows binary operations on LazyValues, so you can add them, multiply
+# them, etc. When you do something like
- inches = Value(8)
- dpi = Value(72)
- width = inches * dpi
+# inches = Value(8)
+# dpi = Value(72)
+# width = inches * dpi
-width is a BinOp instance (that tells you the width of the figure in
-pixels). Later, if the figure size in changed, ie we call
+# width is a BinOp instance (that tells you the width of the figure in
+# pixels). Later, if the figure size in changed, ie we call
- inches.set(10)
+# inches.set(10)
-The width variable is automatically updated because it stores a
-pointer to the inches variable, not the value. Since a BinOp is also
-a lazy value, you can define binary operations on BinOps as well, such
-as
+# The width variable is automatically updated because it stores a
+# pointer to the inches variable, not the value. Since a BinOp is also
+# a lazy value, you can define binary operations on BinOps as well, such
+# as
- middle = Value(0.5) * width
+# middle = Value(0.5) * width
-Pairs of LazyValue instances can occur as instances of two classes:
+# Pairs of LazyValue instances can occur as instances of two classes:
- pt = Point( Value(x), Value(y)) # where x, y are numbers
- pt.x(), pt.y() return Value(x), Value(y))
+# pt = Point( Value(x), Value(y)) # where x, y are numbers
+# pt.x(), pt.y() return Value(x), Value(y))
- iv = Interval( Value(x), Value(y))
- iv.contains(z) returns True if z is in the closed interval
- iv.contains_open(z): same for open interval
- iv.span() returns y-x as a float
- iv.get_bounds() returns (x,y) as a tuple of floats
- iv.set_bounds(x, y) allows input of new floats
- iv.update(seq) updates the bounds to include all elements
- in a sequence of floats
- iv.shift(s) shifts the interval by s, a float
+# iv = Interval( Value(x), Value(y))
+# iv.contains(z) returns True if z is in the closed interval
+# iv.contains_open(z): same for open interval
+# iv.span() returns y-x as a float
+# iv.get_bounds() returns (x,y) as a tuple of floats
+# iv.set_bounds(x, y) allows input of new floats
+# iv.update(seq) updates the bounds to include all elements
+# in a sequence of floats
+# iv.shift(s) shifts the interval by s, a float
-The bounding box class Bbox is also heavily used, and is defined by a
-lower left point ll and an upper right point ur. The points ll and ur
-are given by Point(x, y) instances, where x and y are LazyValues. So
-you can represent a point such as
+# The bounding box class Bbox is also heavily used, and is defined by a
+# lower left point ll and an upper right point ur. The points ll and ur
+# are given by Point(x, y) instances, where x and y are LazyValues. So
+# you can represent a point such as
- ll = Point( Value(0), Value(0) ) # the origin
- ur = Point( width, height ) # the upper right of the figure
+# ll = Point( Value(0), Value(0) ) # the origin
+# ur = Point( width, height ) # the upper right of the figure
-where width and height are defined as above, using the product of the
-figure width in inches and the dpi. This is, in face, how the Figure
-bbox is defined
+# where width and height are defined as above, using the product of the
+# figure width in inches and the dpi. This is, in face, how the Figure
+# bbox is defined
- bbox = Bbox(ll, ur)
+# bbox = Bbox(ll, ur)
-A bbox basically defines an x,y coordinate system, with ll giving the
-lower left of the coordinate system and ur giving the upper right.
+# A bbox basically defines an x,y coordinate system, with ll giving the
+# lower left of the coordinate system and ur giving the upper right.
-The bbox methods are
+# The bbox methods are
- ll() - return the lower left Point
- ur() - return the upper right Point
- contains(x,y) - return True if self contains point
- overlaps(bbox) - return True if self overlaps bbox
- overlapsx(bbox) - return True if self overlaps bbox in the x interval
- overlapsy(bbox) - return True if self overlaps bbox in the y interval
- intervalx() - return the x Interval instance
- intervaly() - return the y interval instance
- get_bounds() - get the left, bottom, width, height bounding tuple
- update(xys, ignore) - update the bbox to bound all the xy tuples in
- xys; if ignore is true ignore the current contents of bbox and
- just bound the tuples. If ignore is false, bound self + tuples
- width() - return the width of the bbox
- height() - return the height of the bbox
- xmax() - return the x coord of upper right
- ymax() - return the y coord of upper right
- xmin() - return the x coord of lower left
- ymin() - return the y coord of lower left
- scale(sx,sy) - scale the bbox by sx, sy
- deepcopy() - return a deep copy of self (pointers are lost)
+# ll() - return the lower left Point
+# ur() - return the upper right Point
+# contains(x,y) - return True if self contains point
+# overlaps(bbox) - return True if self overlaps bbox
+# overlapsx(bbox) - return True if self overlaps bbox in the x interval
+# overlapsy(bbox) - return True if self overlaps bbox in the y interval
+# intervalx() - return the x Interval instance
+# intervaly() - return the y interval instance
+# get_bounds() - get the left, bottom, width, height bounding tuple
+# update(xys, ignore) - update the bbox to bound all the xy tuples in
+# xys; if ignore is true ignore the current contents of bbox and
+# just bound the tuples. If ignore is false, bound self + tuples
+# width() - return the width of the bbox
+# height() - return the height of the bbox
+# xmax() - return the x coord of upper right
+# ymax() - return the y coord of upper right
+# xmin() - return the x coord of lower left
+# ymin() - return the y coord of lower left
+# scale(sx,sy) - scale the bbox by sx, sy
+# deepcopy() - return a deep copy of self (pointers are lost)
-The basic transformation maps one bbox to another, with an optional
-nonlinear transformation of one of coordinates (eg log scaling).
+# The basic transformation maps one bbox to another, with an optional
+# nonlinear transformation of one of coordinates (eg log scaling).
-The base class for transformations is Transformation, and the concrete
-derived classes are SeparableTransformation and Affine. Earlier
-versions of matplotlib handled transformation of x and y separately
-(ie we assumed all transformations were separable) but this makes it
-difficult to do rotations or polar transformations, for example. All
-artists contain their own transformation, defaulting to the identity
-transform.
+# The base class for transformations is Transformation, and the concrete
+# derived classes are SeparableTransformation and Affine. Earlier
+# versions of matplotlib handled transformation of x and y separately
+# (ie we assumed all transformations were separable) but this makes it
+# difficult to do rotations or polar transformations, for example. All
+# artists contain their own transformation, defaulting to the identity
+# transform.
-The signature of a separable transformation instance is
+# The signature of a separable transformation instance is
- trans = SeparableTransformation(bbox1, bbox2, funcx, funcy)
+# trans = SeparableTransformation(bbox1, bbox2, funcx, funcy)
-where funcx and funcy operate on x and y. The typical linear
-coordinate transformation maps one bounding box to another, with funcx
-and funcy both identity. Eg,
+# where funcx and funcy operate on x and y. The typical linear
+# coordinate transformation maps one bounding box to another, with funcx
+# and funcy both identity. Eg,
- transData = Transformation(viewLim, displayLim,
- Func(IDENTITY), Func(IDENTITY))
+# transData = Transformation(viewLim, displayLim,
+# Func(IDENTITY), Func(IDENTITY))
-maps the axes view limits to display limits. If the xaxis scaling is
-changed to log, one simply calls
+# maps the axes view limits to display limits. If the xaxis scaling is
+# changed to log, one simply calls
- transData.get_funcx().set_type(LOG10)
+# transData.get_funcx().set_type(LOG10)
-For more general transformations including rotation, the Affine class
-is provided, which is constructed with 6 LazyValue instances:
-a, b, c, d, tx, ty. These give the values of the matrix transformation
+# For more general transformations including rotation, the Affine class
+# is provided, which is constructed with 6 LazyValue instances:
+# a, b, c, d, tx, ty. These give the values of the matrix transformation
- [xo = |a c| [xi + [tx
- yo] |b d| yi] ty]
+# [xo = |a c| [xi + [tx
+# yo] |b d| yi] ty]
-where if sx, sy are the scaling components, tx, y are the translation
-components, and alpha is the rotation
+# where if sx, sy are the scaling components, tx, y are the translation
+# components, and alpha is the rotation
- a = sx*cos(alpha);
- b = -sx*sin(alpha);
- c = sy*sin(alpha);
- d = sy*cos(alpha);
+# a = sx*cos(alpha);
+# b = -sx*sin(alpha);
+# c = sy*sin(alpha);
+# d = sy*cos(alpha);
-The affine transformation can be accomplished for row vectors with a
-single matrix multiplication
- X_new = X_old * M
-where
- M = [ a b 0
- c d 0
- tx ty 1]
-and each X is the row vector [x, y, 1]. Hence M is
-the transpose of the matrix representation given in
-http://en.wikipedia.org/wiki/Affine_transformation,
-which is for the more usual column-vector representation
-of the position.)
+# The affine transformation can be accomplished for row vectors with a
+# single matrix multiplication
+# X_new = X_old * M
+# where
+# M = [ a b 0
+# c d 0
+# tx ty 1]
+# and each X is the row vector [x, y, 1]. Hence M is
+# the transpose of the matrix representation given in
+# http://en.wikipedia.org/wiki/Affine_transformation,
+# which is for the more usual column-vector representation
+# of the position.)
-From a user perspective, the most important Tranformation methods are
+# From a user perspective, the most important Tranformation methods are
-All transformations
--------------------
- freeze() - eval and freeze the lazy objects
- thaw() - release the lazy objects
+# All transformations
+# -------------------
+# freeze() - eval and freeze the lazy objects
+# thaw() - release the lazy objects
- xy_tup(xy) - transform the tuple (x,y)
- seq_x_y(x, y) - transform the python sequences x and y
- numerix_x_y(x, y) - x and y are numerix 1D arrays
- numerix_xy(xy) - xy is a numerix array of shape (N,2)
- inverse_numerix_xy(xy)- inverse of the above
- seq_xy_tups(seq) - seq is a sequence of xy tuples or a (N,2) array
- inverse_xy_tup(xy) - apply the inverse transformation to tuple xy
+# xy_tup(xy) - transform the tuple (x,y)
+# seq_x_y(x, y) - transform the python sequences x and y
+# numerix_x_y(x, y) - x and y are numerix 1D arrays
+# numerix_xy(xy) - xy is a numerix array of shape (N,2)
+# inverse_numerix_xy(xy)- inverse of the above
+# seq_xy_tups(seq) - seq is a sequence of xy tuples or a (N,2) array
+# inverse_xy_tup(xy) - apply the inverse transformation to tuple xy
- set_offset(xy, trans) - xy is an x,y tuple and trans is a
- Transformation instance. This will apply a post transformational
- offset of all future transformations by xt,yt = trans.xy_tup(xy[0], xy[1])
+# set_offset(xy, trans) - xy is an x,y tuple and trans is a
+# Transformation instance. This will apply a post transformational
+# offset of all future transformations by xt,yt = trans.xy_tup(xy[0], xy[1])
- deepcopy() - returns a deep copy; references are lost
- shallowcopy() - returns a shallow copy excluding the offset
+# deepcopy() - returns a deep copy; references are lost
+# shallowcopy() - returns a shallow copy excluding the offset
-Separable transformations
--------------------------
+# Separable transformations
+# -------------------------
- get_bbox1() - return the input bbox
- get_bbox2() - return the output bbox
- set_bbox1() - set the input bbox
- set_bbox2() - set the output bbox
- get_funcx() - return the Func instance on x
- get_funcy() - return the Func instance on y
- set_funcx() - set the Func instance on x
- set_funcy() - set the Func instance on y
+# get_bbox1() - return the input bbox
+# get_bbox2() - return the output bbox
+# set_bbox1() - set the input bbox
+# set_bbox2() - set the output bbox
+# get_funcx() - return the Func instance on x
+# get_funcy() - return the Func instance on y
+# set_funcx() - set the Func instance on x
+# set_funcy() - set the Func instance on y
-Affine transformations
-----------------------
+# Affine transformations
+# ----------------------
- as_vec6() - return the affine as length 6 list of Values
+# as_vec6() - return the affine as length 6 list of Values
-In general, you shouldn't need to construct your own transformations,
-but should use the helper functions defined in this module.
+# In general, you shouldn't need to construct your own transformations,
+# but should use the helper functions defined in this module.
- zero - return Value(0)
- one - return Value(1)
- origin - return Point(zero(), zero())
- unit_bbox - return the 0,0 to 1,1 bounding box
- identity_affine - An affine identity transformation
- identity_transform - An identity separable transformation
- translation_transform - a pure translational affine
- scale_transform - a pure scale affine
- scale_sep_transform - a pure scale separable transformation
- scale_translation_transform - a scale and translate affine
- bound_vertices - return the bbox that bounds all the xy tuples
- bbox_all - return the bbox that bounds all the bboxes
- lbwh_to_bbox - build a bbox from tuple
- left, bottom, width, height tuple
+# zero - return Value(0)
+# one - return Value(1)
+# origin - return Point(zero(), zero())
+# unit_bbox - return the 0,0 to 1,1 bounding box
+# identity_affine - An affine identity transformation
+# identity_transform - An identity separable transformation
+# translation_transform - a pure translational affine
+# scale_transform - a pure scale affine
+# scale_sep_transform - a pure scale separable transformation
+# scale_translation_transform - a scale and translate affine
+# bound_vertices - return the bbox that bounds all the xy tuples
+# bbox_all - return the bbox that bounds all the bboxes
+# lbwh_to_bbox - build a bbox from tuple
+# left, bottom, width, height tuple
- multiply_affines - return the affine that is the matrix product of
- the two affines
+# multiply_affines - return the affine that is the matrix product of
+# the two affines
- get_bbox_transform - return a SeparableTransformation instance that
- transforms one bbox to another
+# get_bbox_transform - return a SeparableTransformation instance that
+# transforms one bbox to another
- blend_xy_sep_transform - mix the x and y components of two separable
- transformations into a new transformation.
- This allows you to specify x and y in
- different coordinate systems
+# blend_xy_sep_transform - mix the x and y components of two separable
+# transformations into a new transformation.
+# This allows you to specify x and y in
+# different coordinate systems
- transform_bbox - apply a transformation to a bbox and return the
- transformed bbox
+# transform_bbox - apply a transformation to a bbox and return the
+# transformed bbox
- inverse_transform_bbox - apply the inverse transformation of a bbox
- and return the inverse transformed bbox
+# inverse_transform_bbox - apply the inverse transformation of a bbox
+# and return the inverse transformed bbox
- offset_copy - make a copy with an offset
+# offset_copy - make a copy with an offset
-The units/transform_unit.py code has many examples.
+# The units/transform_unit.py code has many examples.
-A related and partly overlapping class, PBox, has been added to the
-original transforms module to facilitate Axes repositioning and resizing.
-At present, the differences between Bbox and PBox include:
+# A related and partly overlapping class, PBox, has been added to the
+# original transforms module to facilitate Axes repositioning and resizing.
+# At present, the differences between Bbox and PBox include:
- Bbox works with the bounding box, the coordinates of the lower-left
- and upper-right corners; PBox works with the lower-left coordinates
- and the width, height pair (left, bottom, width, height, or 'lbwh').
- Obviously, these are equivalent, but lbwh is what is used by
- Axes._position, and it is the natural specification for the types of
- manipulations for which the PBox class was made.
+# Bbox works with the bounding box, the coordinates of the lower-left
+# and upper-right corners; PBox works with the lower-left coordinates
+# and the width, height pair (left, bottom, width, height, or 'lbwh').
+# Obviously, these are equivalent, but lbwh is what is used by
+# Axes._position, and it is the natural specification for the types of
+# manipulations for which the PBox class was made.
- Bbox uses LazyValues grouped in pairs as 'll' and 'ur' Point objects;
- PBox uses a 4-element list, subclassed from the python list.
+# Bbox uses LazyValues grouped in pairs as 'll' and 'ur' Point objects;
+# PBox uses a 4-element list, subclassed from the python list.
- Bbox and PBox methods are mostly quite different, reflecting their
- different original purposes. Similarly, the CXX implementation of
- Bbox is good for methods such as update and for lazy evaluation, but
- for PBox intended uses, involving very little calculation, pure
- python probably is adequate.
+# Bbox and PBox methods are mostly quite different, reflecting their
+# different original purposes. Similarly, the CXX implementation of
+# Bbox is good for methods such as update and for lazy evaluation, but
+# for PBox intended uses, involving very little calculation, pure
+# python probably is adequate.
-In the future we may reimplement the PBox using Bbox
-and transforms, or eliminate it entirely by adding its methods
-and attributes to Bbox and/or putting them elsewhere in this module.
-"""
-from __future__ import division
-import math
-import numpy as npy
+# In the future we may reimplement the PBox using Bbox
+# and transforms, or eliminate it entirely by adding its methods
+# and attributes to Bbox and/or putting them elsewhere in this module.
+# """
+# from __future__ import division
+# import math
+# import numpy as npy
-from matplotlib._transforms import Value, Point, Interval, Bbox, Affine
-from matplotlib._transforms import IDENTITY, LOG10, POLAR, Func, FuncXY
-from matplotlib._transforms import SeparableTransformation
-from matplotlib._transforms import NonseparableTransformation
+# from matplotlib._transforms import Value, Point, Interval, Bbox, Affine
+# from matplotlib._transforms import IDENTITY, LOG10, POLAR, Func, FuncXY
+# from matplotlib._transforms import SeparableTransformation
+# from matplotlib._transforms import NonseparableTransformation
-def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
- '''
- Ensure the endpoints of a range are not too close together.
+# def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
+# '''
+# Ensure the endpoints of a range are not too close together.
- "too close" means the interval is smaller than 'tiny' times
- the maximum absolute value.
+# "too close" means the interval is smaller than 'tiny' times
+# the maximum absolute value.
- If they are too close, each will be moved by the 'expander'.
- If 'increasing' is True and vmin > vmax, they will be swapped,
- regardless of whether they are too close.
- '''
- swapped = False
- if vmax < vmin:
- vmin, vmax = vmax, vmin
- swapped = True
- if vmax - vmin <= max(abs(vmin), abs(vmax)) * tiny:
- if vmin==0.0:
- vmin = -expander
- vmax = expander
- else:
- vmin -= expander*abs(vmin)
- vmax += expander*abs(vmax)
- if swapped and not increasing:
- vmin, vmax = vmax, vmin
- return vmin, vmax
+# If they are too close, each will be moved by the 'expander'.
+# If 'increasing' is True and vmin > vmax, they will be swapped,
+# regardless of whether they are too close.
+# '''
+# swapped = False
+# if vmax < vmin:
+# vmin, vmax = vmax, vmin
+# swapped = True
+# if vmax - vmin <= max(abs(vmin), abs(vmax)) * tiny:
+# if vmin==0.0:
+# vmin = -expander
+# vmax = expander
+# else:
+# vmin -= expander*abs(vmin)
+# vmax += expander*abs(vmax)
+# if swapped and not increasing:
+# vmin, vmax = vmax, vmin
+# return vmin, vmax
-def zero(): return Value(0)
+# def zero(): return Value(0)
-def one() : return Value(1)
+# def one() : return Value(1)
-def origin():
- return Point( zero(), zero() )
+# def origin():
+# return Point( zero(), zero() )
-def unit_bbox():
- """
- Get a 0,0 -> 1,1 Bbox instance
- """
- return Bbox( origin(), Point( one(), one() ) )
+# def unit_bbox():
+# """
+# Get a 0,0 -> 1,1 Bbox instance
+# """
+# return Bbox( origin(), Point( one(), one() ) )
-def identity_affine():
- """
- Get an affine transformation that maps x,y -> x,y
- """
+# def identity_affine():
+# """
+# Get an affine transformation that maps x,y -> x,y
+# """
- return Affine(one(), zero(), zero(), one(), zero(), zero())
+# return Affine(one(), zero(), zero(), one(), zero(), zero())
-def identity_transform():
- """
- Get an affine transformation that maps x,y -> x,y
- """
- return SeparableTransformation(unit_bbox(), unit_bbox(),
- Func(IDENTITY),
- Func(IDENTITY))
+# def identity_transform():
+# """
+# Get an affine transformation that maps x,y -> x,y
+# """
+# return SeparableTransformation(unit_bbox(), unit_bbox(),
+# Func(IDENTITY),
+# Func(IDENTITY))
-def translation_transform(tx, ty):
- """
- return a pure tranlational transformation...
[truncated message content] |