SF.net SVN: matplotlib: [3834] trunk/matplotlib/lib/matplotlib
Revision: 3834
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3834&view=rev
Author: jouni
Date: 2007-09-12 00:04:38 -0700 (Wed, 12 Sep 2007)
Log Message:
---
Further development of dviread. It now attempts to read virtual fonts,
but the positioning is still somewhat off.
Modified Paths:
--
trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
trunk/matplotlib/lib/matplotlib/dviread.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-11
19:40:27 UTC (rev 3833)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-12
07:04:38 UTC (rev 3834)
@@ -491,6 +491,7 @@
return fontdictObject
def embedType1(self, filename, fontinfo):
+# TODO: font effects such as SlantFont
fh = open(filename, 'rb')
matplotlib.verbose.report(
'Embedding Type 1 font ' + filename, 'debug')
@@ -520,8 +521,15 @@
if fontinfo.encodingfile is not None:
enc = dviread.Encoding(fontinfo.encodingfile)
-widths = [ afmdata.get_width_from_char_name(ch)
- for ch in enc ]
+widths = []
+for ch in enc:
+try:
+widths.append(afmdata.get_width_from_char_name(ch))
+except KeyError:
+matplotlib.verbose.report(
+'No width for %s in %s' % (ch, fullname), 'debug')
+widths.append(0)
+
differencesArray = [ Name(ch) for ch in enc ]
differencesArray = [ 0 ] + differencesArray
firstchar = 0
@@ -538,11 +546,24 @@
firstchar = not_None.next()
lastchar = max(not_None)
widths = widths[firstchar:lastchar+1]
+for i,w in enumerate(widths):
+if w is None: widths[i] = 0
-differencesArray = [ firstchar ]
+differencesArray = [ ]
+need_idx = True
for ch in range(firstchar, lastchar+1):
-differencesArray.append(Name(
-afmdata.get_name_char(ch, isord=True)))
+try:
+name = afmdata.get_name_char(ch, isord=True)
+if need_idx:
+differencesArray.append(ch)
+need_idx = False
+differencesArray.append(Name(name))
+except KeyError:
+matplotlib.verbose.report(
+'No name for glyph %d in %s' % (ch, fullname),
+'debug')
+need_idx = True
+
fontdict = {
'Type': Name('Font'),
@@ -1448,17 +1469,16 @@
# Gather font information and do some setup for combining
# characters into strings.
-oldfontnum, seq = None, []
-for x1, y1, fontnum, glyph, width in page.text:
-if fontnum != oldfontnum:
-texname, fontsize = dvi.fontinfo(fontnum)
-fontinfo = self.tex_font_mapping(texname)
+oldfont, seq = None, []
+for x1, y1, dvifont, glyph, width in page.text:
+if dvifont != oldfont:
+fontinfo = self.tex_font_mapping(dvifont.texname)
pdfname = self.file.fontName(fontinfo.filename)
self.file.fontInfo[pdfname] = Bunch(
encodingfile=fontinfo.encoding,
afmfile=fontinfo.afm)
-seq += [['font', pdfname, fontsize]]
-oldfontnum = fontnum
+seq += [['font', pdfname, dvifont.size]]
+oldfont = dvifont
seq += [['text', x1, y1, [chr(glyph)], x1+width]]
seq += [('end',)]
Modified: trunk/matplotlib/lib/matplotlib/dviread.py
===
--- trunk/matplotlib/lib/matplotlib/dviread.py 2007-09-11 19:40:27 UTC (rev
3833)
+++ trunk/matplotlib/lib/matplotlib/dviread.py 2007-09-12 07:04:38 UTC (rev
3834)
@@ -9,15 +9,13 @@
for page in dvi: # iterate over pages
w, h, d = page.width, page.height, page.descent
for x,y,font,glyph,width in page.text:
-fontname, pointsize = dvi.fontinfo(font)
+fontname = font.texname
+pointsize = font.size
...
for x,y,height,width in page.boxes:
...
"""
-# TODO: support TeX virtual fonts (*.vf) which are a sort of
-# subroutine collections for dvi files
-
import matplotlib
import matplotlib.cbook as mpl_cbook
import numpy as npy
@@ -85,8 +83,7 @@
x,y,h,w = elt
e = 0 # zero depth
else: # glyph
-x,y,f,g,w = elt
-font = self.
SF.net SVN: matplotlib: [3835] branches/transforms/lib/matplotlib
Revision: 3835 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3835&view=rev Author: mdboom Date: 2007-09-12 06:36:25 -0700 (Wed, 12 Sep 2007) Log Message: --- Second pass, using a stateful transform tree. Modified Paths: -- branches/transforms/lib/matplotlib/affine.py 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/backends/backend_tkagg.py branches/transforms/lib/matplotlib/figure.py branches/transforms/lib/matplotlib/legend.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/table.py branches/transforms/lib/matplotlib/text.py branches/transforms/lib/matplotlib/ticker.py Removed Paths: - branches/transforms/lib/matplotlib/bbox.py Modified: branches/transforms/lib/matplotlib/affine.py === --- branches/transforms/lib/matplotlib/affine.py2007-09-12 07:04:38 UTC (rev 3834) +++ branches/transforms/lib/matplotlib/affine.py2007-09-12 13:36:25 UTC (rev 3835) @@ -6,19 +6,203 @@ import numpy as N from numpy.linalg import inv +from sets import Set -class Transform(object): +# MGDTODO: This creates a ton of cyclical references. We may want to +# consider using weak references + +class TransformNode(object): +def __init__(self): + self._parents = Set() + +def invalidate(self): + if not self._do_invalidation(): + for parent in self._parents: + parent.invalidate() + +def _do_invalidation(self): + return False + +def add_children(self, children): + for child in children: + child._parents.add(self) + +class Bbox(TransformNode): +def __init__(self, points): + TransformNode.__init__(self) + self._points = N.asarray(points, N.float_) + self.track = False + +def __del__(self): + if self.track: + print "Bbox::__del__" + +[EMAIL PROTECTED] +def unit(): + return Bbox([[0,0], [1,1]]) +unit = staticmethod(unit) + +[EMAIL PROTECTED] +def from_lbwh(left, bottom, width, height): + return Bbox([[left, bottom], [left + width, bottom + height]]) +from_lbwh = staticmethod(from_lbwh) + +[EMAIL PROTECTED] +def from_lbrt(left, bottom, right, top): + return Bbox([[left, bottom], [right, top]]) +from_lbrt = staticmethod(from_lbrt) + +def update_from_data(self, x, y): + self._points = N.array([[x.min(), y.min()], [x.max(), y.max()]], N.float_) + self.invalidate() + if self.track: + print "Bbox::update_from_data", self._points + +def copy(self): + if self.track: + print "Bbox::copy" + return Bbox(self._points.copy()) + +def __repr__(self): + return 'Bbox(%s)' % repr(self._points) +__str__ = __repr__ + +def __cmp__(self, other): + # MGDTODO: Totally suboptimal + if isinstance(other, Bbox): + return (self._points == other._points).all() + return -1 + +# MGDTODO: Probably a more efficient ways to do this... +def _get_xmin(self): + if self.track: + print "Bbox::_get_xmin" + return self._points[0, 0] +def _set_xmin(self, val): + print "Bbox::_set_xmin" + self._points[0, 0] = val + self.invalidate() +xmin = property(_get_xmin, _set_xmin) + +def _get_ymin(self): + return self._points[0, 1] +def _set_ymin(self, val): + self._points[0, 1] = val + self.invalidate() +ymin = property(_get_ymin, _set_ymin) + +def _get_xmax(self): + return self._points[1, 0] +def _set_xmax(self, val): + self._points[1, 0] = val + self.invalidate() +xmax = property(_get_xmax, _set_xmax) + +def _get_ymax(self): + return self._points[1, 1] +def _set_ymax(self, val): + self._points[1, 1] = val + self.invalidate() +ymax = property(_get_ymax, _set_ymax) + +def _get_min(self): + return self._points[0] +def _set_min(self, val): + self._points[0] = val + self.invalidate() +min = property(_get_min, _set_min) + +def _get_max(self): + return self._points[1] +def _set_max(self, val): + self._points[1] = val + self.invalidate() +max = property(_get_max, _set_max) + +def _get_intervalx(self): + return self._points[:,0] +def _set_intervalx(self, interval): + self._points[:,0] = interval + self.invalidate() +intervalx = property(_get_intervalx, _set_intervalx) + +def _get_intervaly(self): + return self._points[:,1] +def _set_intervaly(self, interval): + self._points[:,1] = interval + self.invalidate() +intervaly = propert
SF.net SVN: matplotlib: [3837] branches/transforms/lib/matplotlib/pbox.py
Revision: 3837
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3837&view=rev
Author: mdboom
Date: 2007-09-12 07:46:03 -0700 (Wed, 12 Sep 2007)
Log Message:
---
Adding pbox.py
Added Paths:
---
branches/transforms/lib/matplotlib/pbox.py
Added: branches/transforms/lib/matplotlib/pbox.py
===
--- branches/transforms/lib/matplotlib/pbox.py (rev 0)
+++ branches/transforms/lib/matplotlib/pbox.py 2007-09-12 14:46:03 UTC (rev
3837)
@@ -0,0 +1,126 @@
+# MGDTODO: Just included verbatim for now
+
+class PBox(list):
+'''
+A left-bottom-width-height (lbwh) specification of a bounding box,
+such as is used to specify the position of an Axes object within
+a Figure.
+It is a 4-element list with methods for changing the size, shape,
+and position relative to its container.
+'''
+coefs = {'C': (0.5, 0.5),
+ 'SW': (0,0),
+ 'S': (0.5, 0),
+ 'SE': (1.0, 0),
+ 'E': (1.0, 0.5),
+ 'NE': (1.0, 1.0),
+ 'N': (0.5, 1.0),
+ 'NW': (0, 1.0),
+ 'W': (0, 0.5)}
+def __init__(self, box, container=None, llur=False):
+if len(box) != 4:
+raise ValueError("Argument must be iterable of length 4")
+if llur:
+box = [box[0], box[1], box[2]-box[0], box[3]-box[1]]
+list.__init__(self, box)
+self.set_container(container)
+
+def as_llur(self):
+return [self[0], self[1], self[0]+self[2], self[1]+self[3]]
+
+def set_container(self, box=None):
+if box is None:
+box = self
+if len(box) != 4:
+raise ValueError("Argument must be iterable of length 4")
+self._container = list(box)
+
+def get_container(self, box):
+return self._container
+
+def anchor(self, c, container=None):
+'''
+Shift to position c within its container.
+
+c can be a sequence (cx, cy) where cx, cy range from 0 to 1,
+where 0 is left or bottom and 1 is right or top.
+
+Alternatively, c can be a string: C for centered,
+S for bottom-center, SE for bottom-left, E for left, etc.
+
+Optional arg container is the lbwh box within which the
+PBox is positioned; it defaults to the initial
+PBox.
+'''
+if container is None:
+container = self._container
+l,b,w,h = container
+if isinstance(c, str):
+cx, cy = self.coefs[c]
+else:
+cx, cy = c
+W,H = self[2:]
+self[:2] = l + cx * (w-W), b + cy * (h-H)
+return self
+
+def shrink(self, mx, my):
+'''
+Shrink the box by mx in the x direction and my in the y direction.
+The lower left corner of the box remains unchanged.
+Normally mx and my will be <= 1, but this is not enforced.
+'''
+assert mx >= 0 and my >= 0
+self[2:] = mx * self[2], my * self[3]
+return self
+
+def shrink_to_aspect(self, box_aspect, fig_aspect = 1):
+'''
+Shrink the box so that it is as large as it can be while
+having the desired aspect ratio, box_aspect.
+If the box coordinates are relative--that is, fractions of
+a larger box such as a figure--then the physical aspect
+ratio of that figure is specified with fig_aspect, so
+that box_aspect can also be given as a ratio of the
+absolute dimensions, not the relative dimensions.
+'''
+assert box_aspect > 0 and fig_aspect > 0
+l,b,w,h = self._container
+H = w * box_aspect/fig_aspect
+if H <= h:
+W = w
+else:
+W = h * fig_aspect/box_aspect
+H = h
+self[2:] = W,H
+return self
+
+def splitx(self, *args):
+'''
+e.g., PB.splitx(f1, f2, ...)
+
+Returns a list of new PBoxes formed by
+splitting the original one (PB) with vertical lines
+at fractional positions f1, f2, ...
+'''
+boxes = []
+xf = [0] + list(args) + [1]
+l,b,w,h = self[:]
+for xf0, xf1 in zip(xf[:-1], xf[1:]):
+boxes.append(PBox([l+xf0*w, b, (xf1-xf0)*w, h]))
+return boxes
+
+def splity(self, *args):
+'''
+e.g., PB.splity(f1, f2, ...)
+
+Returns a list of new PBoxes formed by
+splitting the original one (PB) with horizontal lines
+at fractional positions f1, f2, ..., with y measured
+positive up.
+'''
+boxes = []
+yf = [0] + list(args) + [1]
+l,b,w,h = self[:]
+for yf0, yf1 in zip(yf[:-1], yf[1:]):
+boxes.append(PBox([l, b+yf0*h, w, (yf1-yf0)*h]))
+return boxes
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source deve
SF.net SVN: matplotlib: [3838] branches/transforms/lib/matplotlib
Revision: 3838
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3838&view=rev
Author: jdh2358
Date: 2007-09-12 08:41:22 -0700 (Wed, 12 Sep 2007)
Log Message:
---
removed Interval from canonical tickers and formatters
Modified Paths:
--
branches/transforms/lib/matplotlib/affine.py
branches/transforms/lib/matplotlib/axis.py
branches/transforms/lib/matplotlib/ticker.py
Modified: branches/transforms/lib/matplotlib/affine.py
===
--- branches/transforms/lib/matplotlib/affine.py2007-09-12 14:46:03 UTC
(rev 3837)
+++ branches/transforms/lib/matplotlib/affine.py2007-09-12 15:41:22 UTC
(rev 3838)
@@ -33,6 +33,9 @@
self._points = N.asarray(points, N.float_)
self.track = False
+# JDH: if you define a del method, the garbage collector won't
+# destory cyclic references, so make sure you either manage these
+# yourself or remove the __del__ after testing
def __del__(self):
if self.track:
print "Bbox::__del__"
@@ -52,6 +55,11 @@
return Bbox([[left, bottom], [right, top]])
from_lbrt = staticmethod(from_lbrt)
+
+# JDH: the update method will update the box limits from the
+# existing limits and the new data; it appears here you are just
+# using the new data. We use an "ignore" flag to specify whether
+# you want to include the existing data or not in the update
def update_from_data(self, x, y):
self._points = N.array([[x.min(), y.min()], [x.max(), y.max()]],
N.float_)
self.invalidate()
Modified: branches/transforms/lib/matplotlib/axis.py
===
--- branches/transforms/lib/matplotlib/axis.py 2007-09-12 14:46:03 UTC (rev
3837)
+++ branches/transforms/lib/matplotlib/axis.py 2007-09-12 15:41:22 UTC (rev
3838)
@@ -855,9 +855,9 @@
ACCEPTS: A Formatter instance
"""
self.major.formatter = formatter
-self.major.formatter.set_view_interval( self.get_view_interval() )
-self.major.formatter.set_data_interval( self.get_data_interval() )
+self.major.formatter.set_axis(self)
+
def set_minor_formatter(self, formatter):
"""
Set the formatter of the minor ticker
@@ -865,8 +865,7 @@
ACCEPTS: A Formatter instance
"""
self.minor.formatter = formatter
-self.minor.formatter.set_view_interval( self.get_view_interval() )
-self.minor.formatter.set_data_interval( self.get_data_interval() )
+self.minor.formatter.set_axis(self)
def set_major_locator(self, locator):
@@ -876,8 +875,7 @@
ACCEPTS: a Locator instance
"""
self.major.locator = locator
-self.major.locator.set_view_interval( self.get_view_interval() )
-self.major.locator.set_data_interval( self.get_data_interval() )
+self.major.locator.set_axis(self)
def set_minor_locator(self, locator):
@@ -887,8 +885,7 @@
ACCEPTS: a Locator instance
"""
self.minor.locator = locator
-self.minor.locator.set_view_interval( self.get_view_interval() )
-self.minor.locator.set_data_interval( self.get_data_interval() )
+self.minor.locator.set_axis(self)
def set_pickradius(self, pickradius):
"""
Modified: branches/transforms/lib/matplotlib/ticker.py
===
--- branches/transforms/lib/matplotlib/ticker.py2007-09-12 14:46:03 UTC
(rev 3837)
+++ branches/transforms/lib/matplotlib/ticker.py2007-09-12 15:41:22 UTC
(rev 3838)
@@ -99,13 +99,7 @@
minor ticks. See the matplotlib.dates module for more information and
examples of using date locators and formatters.
-DEVELOPERS NOTE
-If you are implementing your own class or modifying one of these, it
-is critical that you use viewlim and dataInterval READ ONLY MODE so
-multiple axes can share the same locator w/o side effects!
-
-
"""
@@ -121,37 +115,11 @@
class TickHelper:
+axis = None
+def set_axis(self, axis):
+self.axis = axis
-viewInterval = None
-dataInterval = None
-def verify_intervals(self):
-if self.dataInterval is None:
-raise RuntimeError("You must set the data interval to use this
function")
-
-if self.viewInterval is None:
-raise RuntimeError("You must set the view interval to use this
function")
-
-
-def set_view_interval(self, interval):
-self.viewInterval = interval
-
-def set_data_interval(self, interval):
-self.dataInterval = interval
-
-def set_bounds(self, vmin, vmax):
-'''
-Set dataInterval and viewInterval from numeric vmin, vmax.
-
-This is for stand-alone use of Formatters and/or
-Locators that require these intervals; that is, for
-cases where the Inter
SF.net SVN: matplotlib: [3839] branches/transforms/lib/matplotlib
Revision: 3839 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3839&view=rev Author: mdboom Date: 2007-09-12 10:25:19 -0700 (Wed, 12 Sep 2007) Log Message: --- Milestone -- simple_plot.py working with new affine framework (with the exception of dpi propagation) Modified Paths: -- branches/transforms/lib/matplotlib/affine.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/figure.py branches/transforms/lib/matplotlib/lines.py Modified: branches/transforms/lib/matplotlib/affine.py === --- branches/transforms/lib/matplotlib/affine.py2007-09-12 15:41:22 UTC (rev 3838) +++ branches/transforms/lib/matplotlib/affine.py2007-09-12 17:25:19 UTC (rev 3839) @@ -33,29 +33,29 @@ self._points = N.asarray(points, N.float_) self.track = False -# JDH: if you define a del method, the garbage collector won't -# destory cyclic references, so make sure you either manage these -# yourself or remove the __del__ after testing -def __del__(self): - if self.track: - print "Bbox::__del__" - [EMAIL PROTECTED] def unit(): - return Bbox([[0,0], [1,1]]) + return Bbox.from_lbrt(0., 0., 1., 1.) unit = staticmethod(unit) [EMAIL PROTECTED] def from_lbwh(left, bottom, width, height): - return Bbox([[left, bottom], [left + width, bottom + height]]) + return Bbox.from_lbrt(left, bottom, left + width, bottom + height) from_lbwh = staticmethod(from_lbwh) [EMAIL PROTECTED] -def from_lbrt(left, bottom, right, top): - return Bbox([[left, bottom], [right, top]]) +def from_lbrt(*args): + points = N.array(args, dtype=N.float_).reshape(2, 2) + return Bbox(points) from_lbrt = staticmethod(from_lbrt) - +def __cmp__(self, other): + # MGDTODO: Totally suboptimal + if isinstance(other, Bbox): + if (self._points == other._points).all(): + return 0 + return -1 + # JDH: the update method will update the box limits from the # existing limits and the new data; it appears here you are just # using the new data. We use an "ignore" flag to specify whether @@ -63,31 +63,18 @@ def update_from_data(self, x, y): self._points = N.array([[x.min(), y.min()], [x.max(), y.max()]], N.float_) self.invalidate() - if self.track: - print "Bbox::update_from_data", self._points def copy(self): - if self.track: - print "Bbox::copy" return Bbox(self._points.copy()) def __repr__(self): return 'Bbox(%s)' % repr(self._points) __str__ = __repr__ -def __cmp__(self, other): - # MGDTODO: Totally suboptimal - if isinstance(other, Bbox): - return (self._points == other._points).all() - return -1 - # MGDTODO: Probably a more efficient ways to do this... def _get_xmin(self): - if self.track: - print "Bbox::_get_xmin" return self._points[0, 0] def _set_xmin(self, val): - print "Bbox::_set_xmin" self._points[0, 0] = val self.invalidate() xmin = property(_get_xmin, _set_xmin) @@ -150,10 +137,10 @@ height = property(_get_height) def transformed(self, transform): - return Bbox(self.transform(self._points)) + return Bbox(transform(self._points)) def inverse_transformed(self, transform): - return Bbox(self.transform.inverted()(self._points)) + return Bbox(transform.inverted()(self._points)) def get_bounds(self): return (self.xmin, self.ymin, @@ -249,6 +236,14 @@ return "Affine2D(%s)" % repr(self._mtx) __str__ = __repr__ +def __cmp__(self, other): + # MGDTODO: We need to decide if we want deferred transforms + # to be equal to this one + if isinstance(other, Affine2D): + if (self.get_matrix() == other.get_matrix()).all(): + return 0 + return -1 + def _do_invalidation(self): result = self._inverted is None self._inverted = None @@ -380,10 +375,9 @@ if self._mtx is None: x_mtx = self._x.get_matrix() y_mtx = self._y.get_matrix() + # This works because we already know the transforms are + # separable self._mtx = N.vstack([x_mtx[0], y_mtx[1], [0.0, 0.0, 1.0]]) -# self._mtx = self.matrix_from_values( -# x_mtx[0,0], 0.0, 0.0, y_mtx[1,1], x_mtx[0,2], y_mtx[1,2]) - print "Blended", x_mtx, y_mtx, self._mtx def is_separable(self): return True @@ -429,8 +423,8 @@ def _make__mtx(self): if self._mtx is None: self._mtx = self._concat( - self._b.get_matrix(), - self._a.get_matrix()) + self._a.get_matrix(), +
SF.net SVN: matplotlib: [3840] trunk/toolkits/basemap/src
Revision: 3840
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3840&view=rev
Author: jswhit
Date: 2007-09-12 11:14:38 -0700 (Wed, 12 Sep 2007)
Log Message:
---
fix isnan check
Modified Paths:
--
trunk/toolkits/basemap/src/_geod.c
trunk/toolkits/basemap/src/_geod.pyx
Modified: trunk/toolkits/basemap/src/_geod.c
===
--- trunk/toolkits/basemap/src/_geod.c 2007-09-12 17:25:19 UTC (rev 3839)
+++ trunk/toolkits/basemap/src/_geod.c 2007-09-12 18:14:38 UTC (rev 3840)
@@ -1,4 +1,4 @@
-/* Generated by Pyrex 0.9.6.3 on Fri Aug 31 08:42:50 2007 */
+/* Generated by Pyrex 0.9.6.5 on Wed Sep 12 12:12:33 2007 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -12,6 +12,8 @@
#define PY_SSIZE_T_MIN INT_MIN
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) PyInt_AsLong(o)
+ #define PyNumber_Index(o)PyNumber_Int(o)
+ #define PyIndex_Check(o) PyNumber_Check(o)
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
@@ -37,6 +39,8 @@
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+#define __pyx_PyIndex_AsSsize_t(b) PyInt_AsSsize_t(PyNumber_Index(b))
+
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) :
(Py_INCREF(Py_False), Py_False))
static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
if (x == Py_True) return 1;
@@ -337,15 +341,13 @@
static PyObject *__pyx_n___class__;
-static PyObject *__pyx_f_5_geod_4Geod___reduce__(PyObject *__pyx_v_self,
PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_5_geod_4Geod___reduce__(PyObject *__pyx_v_self,
PyObject *unused); /*proto*/
static char __pyx_doc_5_geod_4Geod___reduce__[] = "special method that allows
pyproj.Geod instance to be pickled";
-static PyObject *__pyx_f_5_geod_4Geod___reduce__(PyObject *__pyx_v_self,
PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_f_5_geod_4Geod___reduce__(PyObject *__pyx_v_self,
PyObject *unused) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
- static char *__pyx_argnames[] = {0};
- if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "",
__pyx_argnames))) return 0;
Py_INCREF(__pyx_v_self);
/* "/Volumes/User/jwhitaker/python/pyproj/_geod.pyx":27
@@ -421,6 +423,7 @@
PyObject *__pyx_5 = 0;
Py_ssize_t __pyx_6;
double __pyx_7;
+ int __pyx_8;
static char *__pyx_argnames[] = {"lons","lats","az","dist","radians",0};
__pyx_v_radians = __pyx_k3;
if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O",
__pyx_argnames, &__pyx_v_lons, &__pyx_v_lats, &__pyx_v_az, &__pyx_v_dist,
&__pyx_v_radians))) return 0;
@@ -571,7 +574,7 @@
__pyx_5 = PyNumber_Divide(__pyx_3, __pyx_4); if (unlikely(!__pyx_5))
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_6 = PyInt_AsSsize_t(__pyx_5); if (unlikely(PyErr_Occurred()))
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
+ __pyx_6 = __pyx_PyIndex_AsSsize_t(__pyx_5); if (unlikely(PyErr_Occurred()))
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
__pyx_v_ndim = __pyx_6;
@@ -781,7 +784,7 @@
* geod_for(&self.geodesic_t)
* if pj_errno != 0: # <<
* raise RuntimeError(pj_strerrno(pj_errno))
- * if isnan(self.geodesic_t.ALPHA21) == FP_NAN:
+ * if isnan(self.geodesic_t.ALPHA21):
*/
__pyx_1 = (pj_errno != 0);
if (__pyx_1) {
@@ -790,7 +793,7 @@
* geod_for(&self.geodesic_t)
* if pj_errno != 0:
* raise RuntimeError(pj_strerrno(pj_errno)) #
<<
- * if isnan(self.geodesic_t.ALPHA21) == FP_NAN:
+ * if isnan(self.geodesic_t.ALPHA21):
* raise ValueError('undefined forward geodesic (may be an
equatorial arc)')
*/
__pyx_3 = PyString_FromString(pj_strerrno(pj_errno)); if
(unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto
__pyx_L1;}
@@ -809,16 +812,16 @@
/* "/Volumes/User/jwhitaker/python/pyproj/_geod.pyx":73
* if pj_errno != 0:
* raise RuntimeError(pj_strerrno(pj_errno))
- * if isnan(self.geodesic_t.ALPHA21) == FP_NAN: #
<<
+ * if isnan(self.geodesic_t.ALPHA21): # <<
* raise ValueError('undefined forward geodesic (may be an
equatorial arc)')
* if radians:
*/
-__pyx_2 = (isnan(((struct __pyx_obj_5_geod_Geod
*)__pyx_v_self)->geodesic_t.ALPHA21) == FP_NAN);
-if (__pyx_2) {
+__pyx_8 = isnan(((st
SF.net SVN: matplotlib: [3841] trunk/toolkits/basemap/src
Revision: 3841
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3841&view=rev
Author: jswhit
Date: 2007-09-12 11:22:24 -0700 (Wed, 12 Sep 2007)
Log Message:
---
regenerate with Cython 0.9.6.6
Modified Paths:
--
trunk/toolkits/basemap/src/_geod.c
trunk/toolkits/basemap/src/_proj.c
Modified: trunk/toolkits/basemap/src/_geod.c
===
--- trunk/toolkits/basemap/src/_geod.c 2007-09-12 18:14:38 UTC (rev 3840)
+++ trunk/toolkits/basemap/src/_geod.c 2007-09-12 18:22:24 UTC (rev 3841)
@@ -1,4 +1,4 @@
-/* Generated by Pyrex 0.9.6.5 on Wed Sep 12 12:12:33 2007 */
+/* Generated by Cython 0.9.6.6 on Wed Sep 12 12:20:59 2007 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -50,8 +50,14 @@
#ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x) (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x) (x)
#define unlikely(x) (x)
Modified: trunk/toolkits/basemap/src/_proj.c
===
--- trunk/toolkits/basemap/src/_proj.c 2007-09-12 18:14:38 UTC (rev 3840)
+++ trunk/toolkits/basemap/src/_proj.c 2007-09-12 18:22:24 UTC (rev 3841)
@@ -1,4 +1,4 @@
-/* Generated by Pyrex 0.9.6.3 on Fri Aug 31 08:42:47 2007 */
+/* Generated by Cython 0.9.6.6 on Wed Sep 12 12:21:02 2007 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -12,6 +12,8 @@
#define PY_SSIZE_T_MIN INT_MIN
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) PyInt_AsLong(o)
+ #define PyNumber_Index(o)PyNumber_Int(o)
+ #define PyIndex_Check(o) PyNumber_Check(o)
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
@@ -37,6 +39,8 @@
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+#define __pyx_PyIndex_AsSsize_t(b) PyInt_AsSsize_t(PyNumber_Index(b))
+
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) :
(Py_INCREF(Py_False), Py_False))
static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
if (x == Py_True) return 1;
@@ -46,8 +50,14 @@
#ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x) (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x) (x)
#define unlikely(x) (x)
@@ -111,13 +121,10 @@
static PyObject *__pyx_k2p;
-static PyObject *__pyx_f_5_proj_set_datapath(PyObject *__pyx_self, PyObject
*__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_5_proj_set_datapath(PyObject *__pyx_self, PyObject
*__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_datapath = 0;
+static PyObject *__pyx_f_5_proj_set_datapath(PyObject *__pyx_self, PyObject
*__pyx_v_datapath); /*proto*/
+static PyObject *__pyx_f_5_proj_set_datapath(PyObject *__pyx_self, PyObject
*__pyx_v_datapath) {
char (*__pyx_v_searchpath);
PyObject *__pyx_r;
- static char *__pyx_argnames[] = {"datapath",0};
- if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O",
__pyx_argnames, &__pyx_v_datapath))) return 0;
Py_INCREF(__pyx_v_datapath);
/* "/Volumes/User/jwhitaker/python/pyproj/_proj.pyx":7
@@ -401,15 +408,13 @@
static PyObject *__pyx_n___class__;
-static PyObject *__pyx_f_5_proj_4Proj___reduce__(PyObject *__pyx_v_self,
PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_5_proj_4Proj___reduce__(PyObject *__pyx_v_self,
PyObject *unused); /*proto*/
static char __pyx_doc_5_proj_4Proj___reduce__[] = "special method that allows
pyproj.Proj instance to be pickled";
-static PyObject *__pyx_f_5_proj_4Proj___reduce__(PyObject *__pyx_v_self,
PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_f_5_proj_4Proj___reduce__(PyObject *__pyx_v_self,
PyObject *unused) {
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
- static char *__pyx_argnames[] = {0};
- if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "",
__pyx_argnames))) return 0;
Py_INCREF(__pyx_v_self);
/* "/Volumes/User/jwhitaker/python/pyproj/_proj.pyx":37
@@ -570,7 +575,7 @@
__pyx_4 = PyNumber_Divide(__pyx_2, __pyx_3); if (unlikely(!__pyx_4))
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_5 = PyInt_AsSsize_t(__pyx_4); if (unlikely(PyErr_Occurred()))
{__pyx_filename = __pyx_f[0]; __pyx_lineno
SF.net SVN: matplotlib: [3842] branches/transforms/lib/matplotlib
Revision: 3842
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3842&view=rev
Author: mdboom
Date: 2007-09-12 12:47:56 -0700 (Wed, 12 Sep 2007)
Log Message:
---
More progress. Zooming and panning working thanks to John's patch.
Modified Paths:
--
branches/transforms/lib/matplotlib/affine.py
branches/transforms/lib/matplotlib/artist.py
branches/transforms/lib/matplotlib/axes.py
branches/transforms/lib/matplotlib/backend_bases.py
branches/transforms/lib/matplotlib/backends/backend_agg.py
branches/transforms/lib/matplotlib/backends/backend_tkagg.py
Modified: branches/transforms/lib/matplotlib/affine.py
===
--- branches/transforms/lib/matplotlib/affine.py2007-09-12 18:22:24 UTC
(rev 3841)
+++ branches/transforms/lib/matplotlib/affine.py2007-09-12 19:47:56 UTC
(rev 3842)
@@ -8,9 +8,16 @@
from numpy.linalg import inv
from sets import Set
+# MGDTODO: The name of this module is bad, since it deals with
+# non-affine transformations as well. It should probably just be
+# "transforms", but we already had one of those... ;)
+
# MGDTODO: This creates a ton of cyclical references. We may want to
# consider using weak references
+# MGDTODO: deep copying is probably incorrect wrt the parent/child
+# relationships
+
class TransformNode(object):
def __init__(self):
self._parents = Set()
@@ -48,29 +55,31 @@
points = N.array(args, dtype=N.float_).reshape(2, 2)
return Bbox(points)
from_lbrt = staticmethod(from_lbrt)
+
+def __copy__(self):
+ return Bbox(self._points.copy())
+def __deepcopy__(self, memo):
+ return Bbox(self._points.copy())
+
def __cmp__(self, other):
# MGDTODO: Totally suboptimal
- if isinstance(other, Bbox):
- if (self._points == other._points).all():
- return 0
+ if isinstance(other, Bbox) and (self._points == other._points).all():
+ return 0
return -1
-
+
+def __repr__(self):
+ return 'Bbox(%s)' % repr(self._points)
+__str__ = __repr__
+
# JDH: the update method will update the box limits from the
# existing limits and the new data; it appears here you are just
# using the new data. We use an "ignore" flag to specify whether
# you want to include the existing data or not in the update
-def update_from_data(self, x, y):
+def update_from_data(self, x, y, ignore=True):
self._points = N.array([[x.min(), y.min()], [x.max(), y.max()]],
N.float_)
self.invalidate()
-
-def copy(self):
- return Bbox(self._points.copy())
-def __repr__(self):
- return 'Bbox(%s)' % repr(self._points)
-__str__ = __repr__
-
# MGDTODO: Probably a more efficient ways to do this...
def _get_xmin(self):
return self._points[0, 0]
@@ -136,19 +145,24 @@
return self.ymax - self.ymin
height = property(_get_height)
+def _get_bounds(self):
+ return (self.xmin, self.ymin,
+ self.xmax - self.xmin, self.ymax - self.ymin)
+def _set_bounds(self, bounds):
+ l,b,w,h = bounds
+ self._points = N.array([[l, b], [l+w, b+h]], N.float_)
+ self.invalidate()
+bounds = property(_get_bounds, _set_bounds)
+
def transformed(self, transform):
return Bbox(transform(self._points))
def inverse_transformed(self, transform):
return Bbox(transform.inverted()(self._points))
-def get_bounds(self):
- return (self.xmin, self.ymin,
- self.xmax - self.xmin, self.ymax - self.ymin)
-
def expanded(self, sw, sh):
- width = self.width()
- height = self.height()
+ width = self.width
+ height = self.height
deltaw = (sw * width - width) / 2.0
deltah = (sh * height - height) / 2.0
a = N.array([[-deltaw, -deltah], [deltaw, deltah]])
@@ -199,6 +213,9 @@
if isinstance(other, Transform):
return composite_transform_factory(other, self)
raise TypeError("Can not add Transform to object of type '%s'" %
type(other))
+
+def transform_point(self, point):
+ return self.__call__([point])[0]
def has_inverse(self):
raise NotImplementedError()
@@ -211,49 +228,27 @@
def is_affine(self):
return False
-
-class Affine2D(Transform):
+
+# MGDTODO: Separate out Affine2DBase / Affine2DConcrete so BlendedAffine and
CompositeAffine don't have translate/scale/rotate members
+
+class Affine2DBase(Transform):
input_dims = 2
output_dims = 2
-
-def __init__(self, matrix = None):
-"""
-Initialize an Affine transform from a 3x3 numpy float array.
-a c e
-b d f
-0 0 1
-"""
+def __init__(self):
Transform.__init__(self)
- if matrix is None:
- matrix = N.identity(3)
- el
SF.net SVN: matplotlib: [3843] branches/transforms/lib/matplotlib/backends
Revision: 3843 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3843&view=rev Author: jdh2358 Date: 2007-09-12 13:25:17 -0700 (Wed, 12 Sep 2007) Log Message: --- minor changes for gtk navigation Modified Paths: -- branches/transforms/lib/matplotlib/backends/backend_gtk.py branches/transforms/lib/matplotlib/backends/backend_gtkagg.py Modified: branches/transforms/lib/matplotlib/backends/backend_gtk.py === --- branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-09-12 19:47:56 UTC (rev 3842) +++ branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-09-12 20:25:17 UTC (rev 3843) @@ -405,8 +405,8 @@ self.toolbar = self._get_toolbar(canvas) # calculate size for window -w = int (self.canvas.figure.bbox.width()) -h = int (self.canvas.figure.bbox.height()) +w = int (self.canvas.figure.bbox.width) +h = int (self.canvas.figure.bbox.height) if self.toolbar is not None: self.toolbar.show() @@ -518,7 +518,7 @@ gc = drawable.new_gc() -height = self.canvas.figure.bbox.height() +height = self.canvas.figure.bbox.height y1 = height - y1 y0 = height - y0 @@ -639,8 +639,8 @@ toolfig.subplots_adjust(top=0.9) tool = SubplotTool(self.canvas.figure, toolfig) -w = int (toolfig.bbox.width()) -h = int (toolfig.bbox.height()) +w = int (toolfig.bbox.width) +h = int (toolfig.bbox.height) window = gtk.Window() Modified: branches/transforms/lib/matplotlib/backends/backend_gtkagg.py === --- branches/transforms/lib/matplotlib/backends/backend_gtkagg.py 2007-09-12 19:47:56 UTC (rev 3842) +++ branches/transforms/lib/matplotlib/backends/backend_gtkagg.py 2007-09-12 20:25:17 UTC (rev 3843) @@ -60,8 +60,9 @@ w,h = widget.window.get_size() if w==1 or h==1: return # empty fig + # dpival = self.figure.dpi.get() MGDTODO # compute desired figure size in inches -dpival = self.figure.dpi.get() +dpival = self.figure.dpi winch = w/dpival hinch = h/dpival self.figure.set_size_inches(winch, hinch) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib: [3844] trunk/matplotlib
Revision: 3844
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3844&view=rev
Author: jdh2358
Date: 2007-09-12 13:37:41 -0700 (Wed, 12 Sep 2007)
Log Message:
---
fixed a bar units bug
Modified Paths:
--
trunk/matplotlib/API_CHANGES
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/artist.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/axis.py
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/lib/matplotlib/patches.py
Added Paths:
---
trunk/matplotlib/examples/units/bar_demo2.py
Modified: trunk/matplotlib/API_CHANGES
===
--- trunk/matplotlib/API_CHANGES2007-09-12 20:25:17 UTC (rev 3843)
+++ trunk/matplotlib/API_CHANGES2007-09-12 20:37:41 UTC (rev 3844)
@@ -1,3 +1,5 @@
+Made skiprows=1 the default on csv2rec
+
The gd and paint backends have been deleted.
The errorbar method and function now accept additional kwargs
Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG 2007-09-12 20:25:17 UTC (rev 3843)
+++ trunk/matplotlib/CHANGELOG 2007-09-12 20:37:41 UTC (rev 3844)
@@ -1,3 +1,7 @@
+2007-09-12 Fixed a Axes.bar unit bug - JDH
+
+2007-09-10 Made skiprows=1 the default on csv2rec - JDH
+
2007-09-09 Split out the plotting part of pylab and put it in
pyplot.py; removed numerix from the remaining pylab.py,
which imports everything from pyplot.py. The intention
Added: trunk/matplotlib/examples/units/bar_demo2.py
===
--- trunk/matplotlib/examples/units/bar_demo2.py
(rev 0)
+++ trunk/matplotlib/examples/units/bar_demo2.py2007-09-12 20:37:41 UTC
(rev 3844)
@@ -0,0 +1,34 @@
+"""
+plot using a variety of cm vs inches conversions. The example shows
+how default unit instrospection works (ax1), how various keywords can
+be used to set the x and y units to override the defaults (ax2, ax3,
+ax4) and how one can set the xlimits using scalars (ax3, current units
+assumed) or units (conversions applied to get the numbers to current
+units)
+
+"""
+from basic_units import cm, inch
+from pylab import figure, show, nx
+
+cms = cm *nx.arange(0, 10, 2)
+bottom=0*cm
+width=0.8*cm
+
+fig = figure()
+
+ax1 = fig.add_subplot(2,2,1)
+ax1.bar(cms, cms, bottom=bottom)
+
+ax2 = fig.add_subplot(2,2,2)
+ax2.bar(cms, cms, bottom=bottom, width=width, xunits=cm, yunits=inch)
+
+ax3 = fig.add_subplot(2,2,3)
+ax3.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=cm)
+ax3.set_xlim(3, 6) # scalars are interpreted in current units
+
+ax4 = fig.add_subplot(2,2,4)
+ax4.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=inch)
+#fig.savefig('simple_conversion_plot.png')
+ax4.set_xlim(3*cm, 6*cm) # cm are converted to inches
+
+show()
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===
--- trunk/matplotlib/lib/matplotlib/artist.py 2007-09-12 20:25:17 UTC (rev
3843)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2007-09-12 20:37:41 UTC (rev
3844)
@@ -51,7 +51,7 @@
self._remove_method = None
def remove(self):
-'''
+"""
Remove the artist from the figure if possible. The effect will not
be visible until the figure is redrawn, e.g., with ax.draw_idle().
Call ax.relim() to update the axes limits if desired.
@@ -60,7 +60,7 @@
was added to axes with autolim=True.
Note: there is no support for removing the artist's legend entry.
-'''
+"""
# There is no method to set the callback. Instead the parent should
set
# the _remove_method attribute directly. This would be a protected
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2007-09-12 20:25:17 UTC (rev
3843)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2007-09-12 20:37:41 UTC (rev
3844)
@@ -1198,23 +1198,27 @@
def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
'look for unit kwargs and update the axis instances as necessary'
-if self.xaxis is None or self.xaxis is None: return
+if self.xaxis is None or self.yaxis is None: return
-
+#print 'processing', self.get_geometry()
if xdata is not None:
self.xaxis.update_units(xdata)
+#print '\tset from xdata', self.xaxis.units
if ydata is not None:
self.yaxis.update_units(ydata)
+#print '\tset from ydata', self.yaxis.units
# process kwargs 2nd since these will override default units
if kwargs is not None:
xunits = kwargs.pop( 'xunits', self.xaxis.
SF.net SVN: matplotlib: [3845] trunk/matplotlib
Revision: 3845 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3845&view=rev Author: jouni Date: 2007-09-12 23:29:14 -0700 (Wed, 12 Sep 2007) Log Message: --- More work on dviread and usetex in pdf. It is more usable now, so I am renaming the method from _draw_tex to draw_tex. Modified Paths: -- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/dviread.py Modified: trunk/matplotlib/CHANGELOG === --- trunk/matplotlib/CHANGELOG 2007-09-12 20:37:41 UTC (rev 3844) +++ trunk/matplotlib/CHANGELOG 2007-09-13 06:29:14 UTC (rev 3845) @@ -1,3 +1,6 @@ +2007-09-13 The usetex support in the pdf backend is more usable now, + so I am enabling it. - JKS + 2007-09-12 Fixed a Axes.bar unit bug - JDH 2007-09-10 Made skiprows=1 the default on csv2rec - JDH Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py === --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-12 20:37:41 UTC (rev 3844) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-13 06:29:14 UTC (rev 3845) @@ -527,7 +527,7 @@ widths.append(afmdata.get_width_from_char_name(ch)) except KeyError: matplotlib.verbose.report( -'No width for %s in %s' % (ch, fullname), 'debug') +'No width for %s in %s' % (ch, fullname), 'debug-annoying') widths.append(0) differencesArray = [ Name(ch) for ch in enc ] @@ -561,7 +561,7 @@ except KeyError: matplotlib.verbose.report( 'No name for glyph %d in %s' % (ch, fullname), -'debug') +'debug-annoying') need_idx = True @@ -1449,9 +1449,7 @@ # Pop off the global transformation self.file.output(Op.grestore) -def _draw_tex(self, gc, x, y, s, prop, angle): -# Rename to draw_tex to enable - +def draw_tex(self, gc, x, y, s, prop, angle): texmanager = self.get_texmanager() fontsize = prop.get_size_in_points() dvifile = texmanager.make_dvi(s, fontsize) @@ -1494,7 +1492,7 @@ elt[3][-1] += next[3][0] elt[4] += next[4]-next[1] else: -elt[3] += [offset, next[3][0]] +elt[3] += [offset*1000.0/dvifont.size, next[3][0]] elt[4] = next[4] del seq[i+1] continue Modified: trunk/matplotlib/lib/matplotlib/dviread.py === --- trunk/matplotlib/lib/matplotlib/dviread.py 2007-09-12 20:37:41 UTC (rev 3844) +++ trunk/matplotlib/lib/matplotlib/dviread.py 2007-09-13 06:29:14 UTC (rev 3845) @@ -84,16 +84,22 @@ e = 0 # zero depth else: # glyph x,y,font,g,w = elt -h = (font.scale * font.tfm.height[g]) >> 20 -e = (font.scale * font.tfm.depth[g]) >> 20 +h = _mul2012(font._scale, font._tfm.height[g]) +e = _mul2012(font._scale, font._tfm.depth[g]) minx = min(minx, x) miny = min(miny, y - h) maxx = max(maxx, x + w) maxy = max(maxy, y + e) maxy_pure = max(maxy_pure, y) +if self.dpi is None: +# special case for ease of debugging: output raw dvi coordinates +return mpl_cbook.Bunch(text=self.text, boxes=self.boxes, + width=maxx-minx, height=maxy_pure-miny, + descent=maxy-maxy_pure) + d = self.dpi / (72.27 * 2**16) # from TeX's "scaled points" to dpi units -text = [ ((x-minx)*d, (maxy-y)*d, DviFont(f), g, w*d) +text = [ ((x-minx)*d, (maxy-y)*d, f, g, w*d) for (x,y,f,g,w) in self.text ] boxes = [ ((x-minx)*d, (maxy-y)*d, h*d, w*d) for (x,y,h,w) in self.boxes ] @@ -110,11 +116,11 @@ while True: byte = ord(self.file.read(1)) self._dispatch(byte) -if self.state == _dvistate.inpage: -matplotlib.verbose.report( -'Dvi._read: after %d at %f,%f' % -(byte, self.h, self.v), -'debug-annoying') +# if self.state == _dvistate.inpage: +# matplotlib.verbose.report( +# 'Dvi._read: after %d at %f,%f' % +# (byte, self.h, self.v), +# 'debug-annoying') if byte == 140: # end of page return True if self.state == _dv
