SF.net SVN: matplotlib:[8382] trunk/matplotlib/lib
Revision: 8382 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8382&view=rev Author: leejjoon Date: 2010-06-05 18:31:52 + (Sat, 05 Jun 2010) Log Message: --- mpl_toolkits.axisartist now skips ticklabels of empty string which have caused problem with some TeX installation Modified Paths: -- trunk/matplotlib/lib/matplotlib/texmanager.py trunk/matplotlib/lib/mpl_toolkits/axisartist/axis_artist.py Modified: trunk/matplotlib/lib/matplotlib/texmanager.py === --- trunk/matplotlib/lib/matplotlib/texmanager.py 2010-06-05 04:19:10 UTC (rev 8381) +++ trunk/matplotlib/lib/matplotlib/texmanager.py 2010-06-05 18:31:52 UTC (rev 8382) @@ -577,6 +577,8 @@ """ return width, heigth and descent of the text. """ +if tex.strip() == '': +return 0, 0, 0 if renderer: dpi_fraction = renderer.points_to_pixels(1.) Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/axis_artist.py === --- trunk/matplotlib/lib/mpl_toolkits/axisartist/axis_artist.py 2010-06-05 04:19:10 UTC (rev 8381) +++ trunk/matplotlib/lib/mpl_toolkits/axisartist/axis_artist.py 2010-06-05 18:31:52 UTC (rev 8382) @@ -769,6 +769,7 @@ #self._set_offset_radius(r) for (x, y), a, l in self._locs_angles_labels: +if not l.strip(): continue self._set_ref_angle(a) #+ add_angle self.set_x(x) self.set_y(y) @@ -811,6 +812,7 @@ """ whd_list = [] for (x, y), a, l in self._locs_angles_labels: +if not l.strip(): continue clean_line, ismath = self.is_math_text(l) whd = renderer.get_text_width_height_descent( clean_line, self._fontproperties, ismath=ismath) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8383] trunk/matplotlib/lib/mpl_toolkits/axes_grid1/ axes_grid.py
Revision: 8383
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8383&view=rev
Author: leejjoon
Date: 2010-06-05 18:32:00 + (Sat, 05 Jun 2010)
Log Message:
---
fix type check of axes_class of axes_grid1.Grid
Modified Paths:
--
trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py
===
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py 2010-06-05
18:31:52 UTC (rev 8382)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_grid.py 2010-06-05
18:32:00 UTC (rev 8383)
@@ -219,7 +219,8 @@
axes_class = self._defaultLocatableAxesClass
axes_class_args = {}
else:
-if issubclass(axes_class, maxes.Axes):
+if (type(axes_class)) == type and \
+ issubclass(axes_class,
self._defaultLocatableAxesClass.Axes):
axes_class_args = {}
else:
axes_class, axes_class_args = axes_class
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
--
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8384] trunk/matplotlib/lib/matplotlib/backends/ backend_cairo.py
Revision: 8384
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8384&view=rev
Author: leejjoon
Date: 2010-06-05 18:32:06 + (Sat, 05 Jun 2010)
Log Message:
---
RendererCairo.__init__ calls RendererBase.__init__
Modified Paths:
--
trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
===
--- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2010-06-05
18:32:00 UTC (rev 8383)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2010-06-05
18:32:06 UTC (rev 8384)
@@ -96,6 +96,8 @@
cairo.ImageSurface (cairo.FORMAT_ARGB32,1,1))
self.mathtext_parser = MathTextParser('Cairo')
+RendererBase.__init__(self)
+
def set_ctx_from_surface (self, surface):
self.gc.ctx = cairo.Context (surface)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
--
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8385] trunk/matplotlib/lib/matplotlib/backends/ backend_ps.py
Revision: 8385 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8385&view=rev Author: leejjoon Date: 2010-06-05 18:32:11 + (Sat, 05 Jun 2010) Log Message: --- eps output restores the correct bounding box when convert_psfrags creates a ps in landscape mode Modified Paths: -- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py === --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2010-06-05 18:32:06 UTC (rev 8384) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2010-06-05 18:32:11 UTC (rev 8385) @@ -1284,17 +1284,21 @@ font_preamble = texmanager.get_font_preamble() custom_preamble = texmanager.get_custom_preamble() -convert_psfrags(tmpfile, ps_renderer.psfrag, font_preamble, -custom_preamble, paperWidth, paperHeight, -orientation) +psfrag_rotated = convert_psfrags(tmpfile, ps_renderer.psfrag, + font_preamble, + custom_preamble, paperWidth, paperHeight, + orientation) if rcParams['ps.usedistiller'] == 'ghostscript': -gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox) +gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox, + rotated=psfrag_rotated) elif rcParams['ps.usedistiller'] == 'xpdf': -xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox) +xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox, + rotated=psfrag_rotated) elif rcParams['text.usetex']: if False: pass # for debugging -else: gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox) +else: gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox, + rotated=psfrag_rotated) if isinstance(outfile, file): fh = file(tmpfile) @@ -1395,12 +1399,26 @@ os.remove(outfile) os.remove(epsfile) shutil.move(psfile, tmpfile) + +# check if the dvips created a ps in landscape paper. Somehow, +# above latex+dvips results in a ps file in a landscape mode for a +# certain figure sizes (e.g., 8.3in,5.8in which is a5). And the +# bounding box of the final output got messed up. We check see if +# the generated ps file is in landscape and return this +# information. The return value is used in pstoeps step to recover +# the correct bounding box. 2010-06-05 JJL +if "Landscape" in open(tmpfile).read(1000): +psfrag_rotated = True +else: +psfrag_rotated = False + if not debugPS: for fname in glob.glob(tmpfile+'.*'): os.remove(fname) +return psfrag_rotated -def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None): +def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False): """ Use ghostscript's pswrite or epswrite device to distill a file. This yields smaller files without illegal encapsulated postscript @@ -1434,10 +1452,10 @@ # the input to eps format, but also restores the original bbox. if eps: -pstoeps(tmpfile, bbox) +pstoeps(tmpfile, bbox, rotated=rotated) -def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None): +def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False): """ Use ghostscript's ps2pdf and xpdf's/poppler's pdftops to distill a file. This yields smaller files without illegal encapsulated postscript @@ -1482,20 +1500,26 @@ # 8.61). Thus, the original bbox need to be resotred. if eps: -pstoeps(tmpfile, bbox) +pstoeps(tmpfile, bbox, rotated) for fname in glob.glob(tmpfile+'.*'): os.remove(fname) -def get_bbox_header(l, b, r, t): +def get_bbox_header(lbrt, rotated=False): """ -return a postscript header stringfor the given bbox (l, b, r, t) +return a postscript header stringfor the given bbox lbrt=(l, b, r, t). +Optionally, return rotate command. """ +l, b, r, t = lbrt +if rotated: +rotate = "%.2f %.2f translate\n90 rotate" % (l+r, 0) +else: +rotate = "" bbox_info = 'BoundingBox: %d %d %d %d' % (l, b, np.ceil(r), np.ceil(t)) hires_bbox_info = 'HiResBoundingBox: %.6f %.6f %.6f %.6f' % (l, b, r, t) -return '\n'.join([bbox_info, hires_bbox_info]) +return '\n'.join([bbox_info, hires_bbox_info]), rotate # get_bbox is deprecated. I don't see any reason to use ghostscript to @@ -1543,12 +1567,14 @@ return '\n'.join([bbox_info, hires_bbox_info]) -def pstoeps(tmpfile, bbox): +def pstoeps(tmpfile, bbox, rotated=False): """ Convert the postscript to encapsulated postscript
SF.net SVN: matplotlib:[8386] trunk/matplotlib/lib/matplotlib/image.py
Revision: 8386
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8386&view=rev
Author: leejjoon
Date: 2010-06-06 04:18:53 + (Sun, 06 Jun 2010)
Log Message:
---
Image in non-linear coordinates correctly have their coners at its extents
Modified Paths:
--
trunk/matplotlib/lib/matplotlib/image.py
Modified: trunk/matplotlib/lib/matplotlib/image.py
===
--- trunk/matplotlib/lib/matplotlib/image.py2010-06-05 18:32:11 UTC (rev
8385)
+++ trunk/matplotlib/lib/matplotlib/image.py2010-06-06 04:18:53 UTC (rev
8386)
@@ -135,7 +135,7 @@
raise RuntimeError('The make_image method must be overridden.')
-def _get_unsampled_image(self, A, image_extents, viewlim):
+def _get_unsampled_image(self, A, image_extents, viewlim, noslice=False):
"""
convert numpy array A with given extents ([x1, x2, y1, y2] in
data coordinate) into the Image, given the vielim (should be a
@@ -150,7 +150,7 @@
sx = dxintv/viewlim.width
sy = dyintv/viewlim.height
numrows, numcols = A.shape[:2]
-if sx > 2:
+if noslice is False and sx > 2:
x0 = (viewlim.x0-xmin)/dxintv * numcols
ix0 = max(0, int(x0 - self._filterrad))
x1 = (viewlim.x1-xmin)/dxintv * numcols
@@ -164,7 +164,7 @@
else:
xslice = slice(0, numcols)
-if sy > 2:
+if noslice is False and sy > 2:
y0 = (viewlim.y0-ymin)/dyintv * numrows
iy0 = max(0, int(y0 - self._filterrad))
y1 = (viewlim.y1-ymin)/dyintv * numrows
@@ -246,8 +246,11 @@
draw unsampled image. The renderer should support a draw_image method
with scale parameter.
"""
+
+
im, xmin, ymin, dxintv, dyintv, sx, sy = \
-self._get_unsampled_image(self._A, self.get_extent(),
self.axes.viewLim)
+self._get_unsampled_image(self._A, self.get_extent(),
+ self.axes.viewLim, noslice=True)
if im is None: return # I'm not if this check is required. -JJL
@@ -264,18 +267,23 @@
im._url = self.get_url()
trans = self.get_transform() #axes.transData
-xy = trans.transform_non_affine([(xmin, ymin),
- (xmin+dxintv, ymin+dyintv)])
+xy = trans.transform_non_affine(np.array([(xmin, ymin),
+ (xmin+dxintv, ymin+dyintv)]))
xx1, yy1 = xy[0]
xx2, yy2 = xy[1]
if self._image_skew_coordinate:
# skew the image when required.
+x_llc, x_trc, y_llc, y_trc = self.get_extent()
x_lrc, y_lrc = self._image_skew_coordinate
-xy = trans.transform_non_affine([(x_lrc, y_lrc)])
-xx3, yy3 = xy[0]
+xy = trans.transform_non_affine(np.array([(x_llc, y_llc),
+ (x_trc, y_trc),
+ (x_lrc, y_lrc)]))
+_xx1, _yy1 = xy[0]
+_xx2, _yy2 = xy[1]
+_xx3, _yy3 = xy[2]
-tr_rotate_skew = self._get_rotate_and_skew_transform(xx1, yy1,
xx2, yy2, xx3, yy3)
+tr_rotate_skew = self._get_rotate_and_skew_transform(_xx1, _yy1,
_xx2, _yy2, _xx3, _yy3)
tr = tr_rotate_skew+trans.get_affine()
else:
tr = trans.get_affine()
@@ -509,8 +517,21 @@
if self._A is None:
raise RuntimeError('You must first set the image array or the
image attribute')
+# image is created in the canvas coordinate.
+x1, x2, y1, y2 = self.get_extent()
+trans = self.get_transform()
+xy = trans.transform(np.array([(x1, y1),
+ (x2, y2),
+ ]))
+_x1, _y1 = xy[0]
+_x2, _y2 = xy[1]
+
+transformed_viewLim = mtransforms.TransformedBbox(self.axes.viewLim,
+ trans)
+
im, xmin, ymin, dxintv, dyintv, sx, sy = \
-self._get_unsampled_image(self._A, self.get_extent(),
self.axes.viewLim)
+self._get_unsampled_image(self._A, [_x1, _x2, _y1, _y2],
+ transformed_viewLim)
fc = self.axes.patch.get_facecolor()
bg = mcolors.colorConverter.to_rgba(fc, 0)
@@ -526,8 +547,8 @@
im.set_resample(self._resample)
# the viewport translation
-tx = (xmin-self.axes.viewLim.x0)/dxintv * numcols
-ty = (ymin-self.axes.viewLim.y0)/dyintv * numrows
+tx = (xmin-transformed_viewLim.x0)/dxintv * numcols
+ty = (ymin-transformed_viewLim.y0)/dyintv * numrows
l, b, r, t = self.axes.bbox.extents
widthDisplay = (round(r*magnification) + 0.5) -
(round(l*magnification) - 0.5
