Revision: 3906
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3906&view=rev
Author: mdboom
Date: 2007-10-01 04:53:52 -0700 (Mon, 01 Oct 2007)
Log Message:
-----------
Merged revisions 3896-3905 via svnmerge from
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib
........
r3898 | jdh2358 | 2007-09-28 08:41:08 -0400 (Fri, 28 Sep 2007) | 2 lines
fixed some tick accessor bugs
........
r3899 | jouni | 2007-09-28 11:50:01 -0400 (Fri, 28 Sep 2007) | 3 lines
Catch UnboundLocalError in checkdep_pdftops; it is raised if
no output line of pdftops -v contains the word "version".
........
r3900 | jouni | 2007-09-28 11:57:49 -0400 (Fri, 28 Sep 2007) | 2 lines
More debugging output when using TeX with the pdf backend
........
r3901 | jouni | 2007-09-30 16:08:50 -0400 (Sun, 30 Sep 2007) | 3 lines
use_tex in pdf backend: don't use AFM files,
which are not there in some TeX distros
........
r3902 | efiring | 2007-09-30 16:32:31 -0400 (Sun, 30 Sep 2007) | 4 lines
bugfix by Zack, confirmed by Gary Ruben.
http://sourceforge.net/mailarchive/forum.php?thread_name=d8cf9020703071339y43354eaerbfa1a47d272e5d26%40mail.gmail.com&forum_name=matplotlib-users
........
r3903 | efiring | 2007-09-30 16:47:55 -0400 (Sun, 30 Sep 2007) | 2 lines
Apply patch by Leon Barrett, tracker #1798196
........
r3904 | efiring | 2007-10-01 03:06:43 -0400 (Mon, 01 Oct 2007) | 2 lines
Fixed bug in updating dataLim when an axis is reversed
........
Modified Paths:
--------------
branches/transforms/CHANGELOG
branches/transforms/lib/matplotlib/__init__.py
branches/transforms/lib/matplotlib/axes3d.py
branches/transforms/lib/matplotlib/axis.py
branches/transforms/lib/matplotlib/backends/backend_pdf.py
branches/transforms/lib/matplotlib/dviread.py
branches/transforms/lib/matplotlib/widgets.py
Property Changed:
----------------
branches/transforms/
Property changes on: branches/transforms
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/matplotlib:1-3895
+ /trunk/matplotlib:1-3905
Modified: branches/transforms/CHANGELOG
===================================================================
--- branches/transforms/CHANGELOG 2007-10-01 11:44:54 UTC (rev 3905)
+++ branches/transforms/CHANGELOG 2007-10-01 11:53:52 UTC (rev 3906)
@@ -1,3 +1,10 @@
+2007-09-30 Modified update* methods of Bbox and Interval so they
+ work with reversed axes. Prior to this, trying to
+ set the ticks on a reversed axis failed with an
+ uninformative error message. - EF
+
+2007-09-30 Applied patches to axes3d to fix index error problem - EF
+
2007-09-24 Applied Eike Welk's patch reported on mpl-dev on 2007-09-22
Fixes a bug with multiple plot windows in the qt backend,
ported the changes to backend_qt4 as well - DSD
@@ -2,3 +9,3 @@
-2007-09-21 Changed cbook.reversed to yield the same result as the
+2007-09-21 Changed cbook.reversed to yield the same result as the
python reversed builtin - DSD
Modified: branches/transforms/lib/matplotlib/__init__.py
===================================================================
--- branches/transforms/lib/matplotlib/__init__.py 2007-10-01 11:44:54 UTC
(rev 3905)
+++ branches/transforms/lib/matplotlib/__init__.py 2007-10-01 11:53:52 UTC
(rev 3906)
@@ -270,7 +270,7 @@
v = line.split()[-1]
float(v)
return v
- except (IndexError, ValueError):
+ except (IndexError, ValueError, UnboundLocalError):
return None
def compare_versions(a, b):
Modified: branches/transforms/lib/matplotlib/axes3d.py
===================================================================
--- branches/transforms/lib/matplotlib/axes3d.py 2007-10-01 11:44:54 UTC
(rev 3905)
+++ branches/transforms/lib/matplotlib/axes3d.py 2007-10-01 11:53:52 UTC
(rev 3906)
@@ -510,16 +510,16 @@
#
polys = []
boxes = []
- for rs in npy.arange(0,rows,rstride):
- for cs in npy.arange(0,cols,cstride):
+ for rs in npy.arange(0,rows-1,rstride):
+ for cs in npy.arange(0,cols-1,cstride):
ps = []
corners = []
for a,ta in [(X,tX),(Y,tY),(Z,tZ)]:
- ztop = a[rs][cs:min(cols-1,cs+cstride)]
+ ztop = a[rs][cs:min(cols,cs+cstride+1)]
zleft =
ta[min(cols-1,cs+cstride)][rs:min(rows,rs+rstride+1)]
zbase =
a[min(rows-1,rs+rstride)][cs:min(cols,cs+cstride+1):]
zbase = zbase[::-1]
- zright = ta[cs][rs:min(rows-1,rs+rstride):]
+ zright = ta[cs][rs:min(rows,rs+rstride+1):]
zright = zright[::-1]
corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]])
z = npy.concatenate((ztop,zleft,zbase,zright))
Modified: branches/transforms/lib/matplotlib/axis.py
===================================================================
--- branches/transforms/lib/matplotlib/axis.py 2007-10-01 11:44:54 UTC (rev
3905)
+++ branches/transforms/lib/matplotlib/axis.py 2007-10-01 11:53:52 UTC (rev
3906)
@@ -530,8 +530,11 @@
def get_children(self):
children = [self.label]
- children.extend(self.majorTicks)
- children.extend(self.minorTicks)
+ majorticks = self.get_major_ticks()
+ minorticks = self.get_minor_ticks()
+
+ children.extend(majorticks)
+ children.extend(minorticks)
return children
def cla(self):
@@ -654,7 +657,8 @@
def get_gridlines(self):
'Return the grid lines as a list of Line2D instance'
- return silent_list('Line2D gridline', [tick.gridline for tick in
self.majorTicks])
+ ticks = self.get_major_ticks()
+ return silent_list('Line2D gridline', [tick.gridline for tick in
ticks])
def get_label(self):
'Return the axis label as a Text instance'
@@ -670,14 +674,16 @@
def get_ticklabels(self):
'Return a list of Text instances for ticklabels'
- labels1 = [tick.label1 for tick in self.majorTicks if tick.label1On]
- labels2 = [tick.label2 for tick in self.majorTicks if tick.label2On]
+ ticks = self.get_major_ticks()
+ labels1 = [tick.label1 for tick in ticks if tick.label1On]
+ labels2 = [tick.label2 for tick in ticks if tick.label2On]
return silent_list('Text ticklabel', labels1+labels2)
def get_ticklines(self):
'Return the ticklines lines as a list of Line2D instance'
lines = []
- for tick in self.majorTicks:
+ ticks = self.get_major_ticks()
+ for tick in ticks:
lines.append(tick.tick1line)
lines.append(tick.tick2line)
return silent_list('Line2D ticklines', lines)
@@ -1087,9 +1093,10 @@
"""
assert position == 'top' or position == 'bottom' or position == 'both'
or position == 'default'
- ticks = list(self.majorTicks) # a copy
- ticks.extend( self.minorTicks )
+ ticks = list( self.get_major_ticks() ) # a copy
+ ticks.extend( self.get_minor_ticks() )
+
if position == 'top':
for t in ticks:
t.tick1On = False
@@ -1287,8 +1294,8 @@
"""
assert position == 'left' or position == 'right' or position == 'both'
or position == 'default'
- ticks = list(self.majorTicks) # a copy
- ticks.extend( self.minorTicks )
+ ticks = list( self.get_major_ticks() ) # a copy
+ ticks.extend( self.get_minor_ticks() )
if position == 'right':
self.set_offset_position('right')
Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-10-01
11:44:54 UTC (rev 3905)
+++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-10-01
11:53:52 UTC (rev 3906)
@@ -500,70 +500,15 @@
finally:
fh.close()
- fh = open(fontinfo.afmfile, 'rb')
- matplotlib.verbose.report(
- 'Reading metrics from ' + fontinfo.afmfile, 'debug')
- try:
- afmdata = AFM(fh)
- finally:
- fh.close()
-
font = FT2Font(filename)
- font.attach_file(fontinfo.afmfile)
widthsObject, fontdescObject, fontdictObject, fontfileObject = \
[ self.reserveObject(n) for n in
('font widths', 'font descriptor',
'font dictionary', 'font file') ]
- _, _, fullname, familyname, weight, italic_angle, fixed_pitch, \
- ul_position, ul_thickness = font.get_ps_font_info()
-
- if fontinfo.encodingfile is not None:
- enc = dviread.Encoding(fontinfo.encodingfile)
- 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-annoying')
- widths.append(0)
-
- differencesArray = [ Name(ch) for ch in enc ]
- differencesArray = [ 0 ] + differencesArray
- firstchar = 0
- lastchar = len(differencesArray) - 2
- else:
- widths = [ None for i in range(256) ]
- for ch in range(256):
- try:
- widths[ch] = afmdata.get_width_char(ch, isord=True)
- except KeyError:
- pass
- not_None = [ch for ch in range(256)
- if widths[ch] is not None]
- firstchar = not_None[0]
- lastchar = not_None[-1]
- widths = widths[firstchar:lastchar+1]
- for i,w in enumerate(widths):
- if w is None: widths[i] = 0
-
- differencesArray = [ ]
- need_idx = True
- for ch in range(firstchar, lastchar+1):
- 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-annoying')
- need_idx = True
-
+ firstchar = 0
+ lastchar = len(fontinfo.widths) - 1
fontdict = {
'Type': Name('Font'),
@@ -575,15 +520,22 @@
'FontDescriptor': fontdescObject,
}
- fontdict.update({
- 'Encoding': { 'Type': Name('Encoding'),
- 'Differences': differencesArray },
- })
+ if fontinfo.encodingfile is not None:
+ enc = dviread.Encoding(fontinfo.encodingfile)
+ differencesArray = [ Name(ch) for ch in enc ]
+ differencesArray = [ 0 ] + differencesArray
+ fontdict.update({
+ 'Encoding': { 'Type': Name('Encoding'),
+ 'Differences': differencesArray },
+ })
+ _, _, fullname, familyname, weight, italic_angle, fixed_pitch, \
+ ul_position, ul_thickness = font.get_ps_font_info()
+
flags = 0
if fixed_pitch: flags |= 1 << 0 # fixed width
if 0: flags |= 1 << 1 # TODO: serif
- if 1: flags |= 1 << 2 # TODO: symbolic
+ if 1: flags |= 1 << 2 # TODO: symbolic (most TeX fonts
are)
else: flags |= 1 << 5 # non-symbolic
if italic_angle: flags |= 1 << 6 # italic
if 0: flags |= 1 << 16 # TODO: all caps
@@ -598,33 +550,17 @@
'ItalicAngle': italic_angle,
'Ascent': font.ascender,
'Descent': font.descender,
- 'CapHeight': 1000, # default guess if missing from AFM file
- 'XHeight': afmdata.get_xheight(),
+ 'CapHeight': 1000, # TODO: find this out
+ 'XHeight': 500, # TODO: this one too
'FontFile': fontfileObject,
'FontFamily': familyname,
+ 'StemV': 50, # TODO
+ # (see also revision 3874; but not all TeX distros have AFM files!)
#'FontWeight': a number where 400 = Regular, 700 = Bold
}
- try:
- descriptor['CapHeight'] = afmdata.get_capheight()
- except KeyError:
- pass
- # StemV is obligatory in PDF font descriptors but optional in
- # AFM files. The collection of AFM files in my TeX Live 2007
- # collection has values ranging from 22 to 219, with both
- # median and mode 50, so if the AFM file is silent, I'm
- # guessing 50. -JKS
- StemV = afmdata.get_vertical_stem_width()
- if StemV is None: StemV = 50
- descriptor['StemV'] = StemV
-
- # StemH is entirely optional:
- StemH = afmdata.get_horizontal_stem_width()
- if StemH is not None:
- descriptor['StemH'] = StemH
-
self.writeObject(fontdictObject, fontdict)
- self.writeObject(widthsObject, widths)
+ self.writeObject(widthsObject, fontinfo.widths)
self.writeObject(fontdescObject, descriptor)
t1font = type1font.Type1Font(filename)
@@ -1470,11 +1406,13 @@
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)
+ psfont = self.tex_font_mapping(dvifont.texname)
+ pdfname = self.file.fontName(psfont.filename)
+ if self.file.fontInfo.get(pdfname, None) is None:
+ self.file.fontInfo[pdfname] = Bunch(
+ encodingfile=psfont.encoding,
+ widths=dvifont.widths,
+ dvifont=dvifont)
seq += [['font', pdfname, dvifont.size]]
oldfont = dvifont
seq += [['text', x1, y1, [chr(glyph)], x1+width]]
Modified: branches/transforms/lib/matplotlib/dviread.py
===================================================================
--- branches/transforms/lib/matplotlib/dviread.py 2007-10-01 11:44:54 UTC
(rev 3905)
+++ branches/transforms/lib/matplotlib/dviread.py 2007-10-01 11:53:52 UTC
(rev 3906)
@@ -84,7 +84,7 @@
e = 0 # zero depth
else: # glyph
x,y,font,g,w = elt
- h = _mul2012(font._scale, font._tfm.height[g])
+ 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)
@@ -380,19 +380,21 @@
class DviFont(object):
"""
- Object that holds a font's texname and size and supports comparison.
+ Object that holds a font's texname and size, supports comparison,
+ and knows the widths of glyphs in the same units as the AFM file.
There are also internal attributes (for use by dviread.py) that
are _not_ used for comparison.
The size is in Adobe points (converted from TeX points).
"""
- __slots__ = ('texname', 'size', '_scale', '_vf', '_tfm')
+ __slots__ = ('texname', 'size', 'widths', '_scale', '_vf', '_tfm')
def __init__(self, scale, tfm, texname, vf):
self._scale, self._tfm, self.texname, self._vf = \
scale, tfm, texname, vf
- # TODO: would it make more sense to have the size in dpi units?
self.size = scale * (72.0 / (72.27 * 2**16))
+ self.widths = [ (1000*tfm.width.get(char, 0)) >> 20
+ for char in range(0, max(tfm.width)) ]
def __eq__(self, other):
return self.__class__ == other.__class__ and \
@@ -402,6 +404,10 @@
return not self.__eq__(other)
def _width_of(self, char):
+ """
+ Width of char in dvi units. For internal use by dviread.py.
+ """
+
width = self._tfm.width.get(char, None)
if width is not None:
return _mul2012(width, self._scale)
@@ -598,7 +604,6 @@
fn, enc = result.filename, result.encoding
if fn is not None and not fn.startswith('/'):
result.filename = find_tex_file(fn)
- result.afm = find_tex_file(fn[:-4] + '.afm')
if enc is not None and not enc.startswith('/'):
result.encoding = find_tex_file(result.encoding)
return result
@@ -734,6 +739,9 @@
result = pipe.readline().rstrip()
pipe.close()
+ matplotlib.verbose.report('find_tex_file: %s -> %s' \
+ % (filename, result),
+ 'debug')
return result
# With multiple text objects per figure (e.g. tick labels) we may end
Modified: branches/transforms/lib/matplotlib/widgets.py
===================================================================
--- branches/transforms/lib/matplotlib/widgets.py 2007-10-01 11:44:54 UTC
(rev 3905)
+++ branches/transforms/lib/matplotlib/widgets.py 2007-10-01 11:53:52 UTC
(rev 3906)
@@ -971,14 +971,14 @@
print ' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata)
print ' used button : ', eclick.button
- def toggle_Selector(event):
+ def toggle_selector(event):
print ' Key pressed.'
- if event.key in ['Q', 'q'] and toggle_Selector.RS.active:
+ if event.key in ['Q', 'q'] and toggle_selector.RS.active:
print ' RectangleSelector deactivated.'
- toggle_Selector.RS.set_active(False)
- if event.key in ['A', 'a'] and not toggle_Selector.RS.active:
+ toggle_selector.RS.set_active(False)
+ if event.key in ['A', 'a'] and not toggle_selector.RS.active:
print ' RectangleSelector activated.'
- toggle_Selector.RS.set_active(True)
+ toggle_selector.RS.set_active(True)
x = arange(100)/(99.0)
y = sin(x)
@@ -986,8 +986,8 @@
ax = subplot(111)
ax.plot(x,y)
- toggle_Selector.RS = RectangleSelector(ax, onselect, drawtype='line')
- connect('key_press_event', toggle_Selector)
+ toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='line')
+ connect('key_press_event', toggle_selector)
show()
"""
def __init__(self, ax, onselect, drawtype='box',
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/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins