From: <md...@us...> - 2007-11-06 20:02:18
|
Revision: 4135 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4135&view=rev Author: mdboom Date: 2007-11-06 12:02:07 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Merged revisions 4059-4134 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4061 | jdh2358 | 2007-10-29 14:52:41 -0400 (Mon, 29 Oct 2007) | 2 lines fixed some examples bugs ........ r4062 | jdh2358 | 2007-10-29 15:00:25 -0400 (Mon, 29 Oct 2007) | 2 lines added cohere demo ........ r4072 | dsdale | 2007-10-31 15:43:54 -0400 (Wed, 31 Oct 2007) | 2 lines added STIX fonts ........ r4073 | dsdale | 2007-10-31 15:53:35 -0400 (Wed, 31 Oct 2007) | 2 lines add STIX license agreement ........ r4081 | efiring | 2007-11-01 03:21:00 -0400 (Thu, 01 Nov 2007) | 2 lines Made contour auto level generation work with log color scale ........ r4087 | dsdale | 2007-11-01 10:17:28 -0400 (Thu, 01 Nov 2007) | 2 lines install fonts/otf to mpl-data ........ r4088 | dsdale | 2007-11-01 10:32:52 -0400 (Thu, 01 Nov 2007) | 2 lines dont enable usetex in arrow_demo.py ........ r4092 | dsdale | 2007-11-01 12:56:33 -0400 (Thu, 01 Nov 2007) | 2 lines rm configtest.py from repository ........ r4093 | dsdale | 2007-11-01 12:57:26 -0400 (Thu, 01 Nov 2007) | 2 lines remove STIXFonts zip file ........ r4094 | dsdale | 2007-11-02 08:55:51 -0400 (Fri, 02 Nov 2007) | 2 lines improved ghostscript version checking ........ r4095 | jdh2358 | 2007-11-02 09:13:40 -0400 (Fri, 02 Nov 2007) | 2 lines added Manuel's contour linestyle patch ........ r4096 | dsdale | 2007-11-02 12:37:37 -0400 (Fri, 02 Nov 2007) | 3 lines commit patch 1599876, fixes to qt4agg backend and qt4 blitting demo. Thanks to Phil Thompson. ........ r4097 | jdh2358 | 2007-11-02 14:45:38 -0400 (Fri, 02 Nov 2007) | 2 lines fix unit changes for errorbar_limits code ........ r4106 | efiring | 2007-11-04 21:36:20 -0500 (Sun, 04 Nov 2007) | 2 lines Added easy access to minor tick properties (Pierre G-M) ........ r4107 | mdboom | 2007-11-05 10:45:00 -0500 (Mon, 05 Nov 2007) | 3 lines First pass at getting STIX fonts to work. Support .otf fonts in font_manager.py ........ r4110 | mdboom | 2007-11-05 12:30:08 -0500 (Mon, 05 Nov 2007) | 2 lines Make STIX fonts work. ........ r4112 | efiring | 2007-11-05 14:49:27 -0500 (Mon, 05 Nov 2007) | 2 lines Minor cleanup; removed old ipython hack. ........ r4113 | efiring | 2007-11-05 14:54:49 -0500 (Mon, 05 Nov 2007) | 2 lines make step_demo use npyma ........ r4114 | efiring | 2007-11-05 15:13:00 -0500 (Mon, 05 Nov 2007) | 2 lines Make safezip accept more args; quadmesh_demo cleanup ........ r4115 | mdboom | 2007-11-05 15:42:23 -0500 (Mon, 05 Nov 2007) | 2 lines Fix rcParams bug. ........ r4126 | mdboom | 2007-11-06 13:32:30 -0500 (Tue, 06 Nov 2007) | 3 lines Prevent errors when using OpenType CFF fonts. This means turning off subsetting on backend_pdf, and raising an exception in backend_ps. ........ r4130 | mdboom | 2007-11-06 14:38:29 -0500 (Tue, 06 Nov 2007) | 2 lines Converted STIX fonts from otf to ttf. ........ r4131 | mdboom | 2007-11-06 14:38:57 -0500 (Tue, 06 Nov 2007) | 1 line Removing STIX otf fonts ........ r4132 | mdboom | 2007-11-06 14:39:23 -0500 (Tue, 06 Nov 2007) | 2 lines Converted STIX fonts from otf to ttf. ........ Modified Paths: -------------- branches/transforms/CHANGELOG branches/transforms/examples/animation_blit_qt4.py branches/transforms/examples/arrow_demo.py branches/transforms/examples/backend_driver.py branches/transforms/examples/image_slices_viewer.py branches/transforms/examples/keypress_demo.py branches/transforms/examples/mathtext_examples.py branches/transforms/examples/quadmesh_demo.py branches/transforms/examples/step_demo.py branches/transforms/examples/units/bar_unit_demo.py branches/transforms/lib/matplotlib/__init__.py branches/transforms/lib/matplotlib/_mathtext_data.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/backends/__init__.py branches/transforms/lib/matplotlib/backends/backend_pdf.py branches/transforms/lib/matplotlib/backends/backend_ps.py branches/transforms/lib/matplotlib/backends/backend_qt4agg.py branches/transforms/lib/matplotlib/cbook.py branches/transforms/lib/matplotlib/config/checkdep.py branches/transforms/lib/matplotlib/config/cutils.py branches/transforms/lib/matplotlib/config/mplconfig.py branches/transforms/lib/matplotlib/config/rcsetup.py branches/transforms/lib/matplotlib/contour.py branches/transforms/lib/matplotlib/font_manager.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/pyplot.py branches/transforms/lib/matplotlib/rcsetup.py branches/transforms/lib/matplotlib/text.py branches/transforms/matplotlibrc.template branches/transforms/setup.py Added Paths: ----------- branches/transforms/examples/cohere_demo.py branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz5Sym.ttf branches/transforms/license/LICENSE_STIX Removed Paths: ------------- branches/transforms/lib/matplotlib/config/configtest.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4058 + /trunk/matplotlib:1-4134 Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/CHANGELOG 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,3 +1,9 @@ +2007-11-02 Commited Phil Thompson's patch 1599876, fixes to Qt4Agg + backend and qt4 blitting demo - DSD + +2007-10-31 Made log color scale easier to use with contourf; + automatic level generation now works. - EF + 2007-10-29 TRANSFORMS REFACTORING The primary goal of this refactoring was to make it easier @@ -66,7 +72,6 @@ See API_CHANGES for more low-level information about this refactoring. - 2007-10-24 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF Modified: branches/transforms/examples/animation_blit_qt4.py =================================================================== --- branches/transforms/examples/animation_blit_qt4.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/animation_blit_qt4.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -15,10 +15,14 @@ class BlitQT(QtCore.QObject): def __init__(self): - QtCore.QObject.__init__(self, None) - self.ax = p.subplot(111) self.canvas = self.ax.figure.canvas + + # By making this a child of the canvas we make sure that it is + # destroyed first and avoids a possible exception when the user clicks + # on the window's close box. + QtCore.QObject.__init__(self, self.canvas) + self.cnt = 0 # create the initial line @@ -26,9 +30,14 @@ self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2) self.background = None + self.old_size = 0, 0 def timerEvent(self, evt): - if self.background is None: + # See if the size has changed since last time round. + current_size = self.ax.bbox.width(), self.ax.bbox.height() + + if self.old_size != current_size: + self.old_size = current_size self.background = self.canvas.copy_from_bbox(self.ax.bbox) # restore the clean slate background Modified: branches/transforms/examples/arrow_demo.py =================================================================== --- branches/transforms/examples/arrow_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/arrow_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -11,7 +11,6 @@ """ from pylab import * -rc('text', usetex=True) rates_to_bases={'r1':'AT', 'r2':'TA', 'r3':'GA','r4':'AG','r5':'CA','r6':'AC', \ 'r7':'GT', 'r8':'TG', 'r9':'CT','r10':'TC','r11':'GC','r12':'CG'} numbered_bases_to_rates = dict([(v,k) for k, v in rates_to_bases.items()]) Modified: branches/transforms/examples/backend_driver.py =================================================================== --- branches/transforms/examples/backend_driver.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/backend_driver.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -32,9 +32,10 @@ 'barh_demo.py', 'color_demo.py', 'colorbar_only.py', + 'cohere_demo.py', 'contour_demo.py', 'contourf_demo.py', - 'csd_demo.py', + 'csd_demo.py', 'custom_ticker1.py', 'customize_rc.py', 'date_demo1.py', Copied: branches/transforms/examples/cohere_demo.py (from rev 4132, trunk/matplotlib/examples/cohere_demo.py) =================================================================== --- branches/transforms/examples/cohere_demo.py (rev 0) +++ branches/transforms/examples/cohere_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -0,0 +1,37 @@ +#!/usr/bin/env python +""" +Compute the coherence of two signals +""" +import numpy as n + +from pylab import figure, show + +dt = 0.01 +t = n.arange(0, 30, dt) +Nt = len(t) +nse1 = n.random.randn(Nt) # white noise 1 +nse2 = n.random.randn(Nt) # white noise 2 +r = n.exp(-t/0.05) + +cnse1 = n.convolve(nse1, r)*dt # colored noise 1 +cnse1 = cnse1[:Nt] +cnse2 = n.convolve(nse2, r)*dt # colored noise 2 +cnse2 = cnse2[:Nt] + +# two signals with a coherent part and a random part +s1 = 0.01*n.sin(2*n.pi*10*t) + cnse1 +s2 = 0.01*n.sin(2*n.pi*10*t) + cnse2 + +fig = figure() +ax = fig.add_subplot(211) +ax.plot(t, s1, 'b-', t, s2, 'g-') +ax.set_xlim(0,5) +ax.set_xlabel('time') +ax.set_ylabel('s1 and s2') + +ax = fig.add_subplot(212) +cxy, f = ax.cohere(s1, s2, 256, 1./dt) + +show() + + Modified: branches/transforms/examples/image_slices_viewer.py =================================================================== --- branches/transforms/examples/image_slices_viewer.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/image_slices_viewer.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -17,7 +17,7 @@ self.update() def onscroll(self, event): - + print event.button if event.button=='up': self.ind = numpy.clip(self.ind+1, 0, self.slices-1) else: Modified: branches/transforms/examples/keypress_demo.py =================================================================== --- branches/transforms/examples/keypress_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/keypress_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,21 +1,23 @@ #!/usr/bin/env python """ Show how to connect to keypress events - -Note, on the wx backend on some platforms (eg linux), you have to -first click on the figure before the keypress events are activated. -If you know how to fix this, please email us! """ -from pylab import * +import numpy as n +from pylab import figure, show def press(event): print 'press', event.key - if event.key=='g': - grid() - draw() + if event.key=='x': + visible = xl.get_visible() + xl.set_visible(not visible) + fig.canvas.draw() -connect('key_press_event', press) +fig = figure() +ax = fig.add_subplot(111) -title('press g to toggle grid') -plot(rand(12), rand(12), 'go') +fig.canvas.mpl_connect('key_press_event', press) + +ax.plot(n.random.rand(12), n.random.rand(12), 'go') +xl = ax.set_xlabel('easy come, easy go') + show() Modified: branches/transforms/examples/mathtext_examples.py =================================================================== --- branches/transforms/examples/mathtext_examples.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/mathtext_examples.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -48,7 +48,8 @@ r'$\mathcal{H} = \int d \tau \left(\epsilon E^2 + \mu H^2\right)$', r'$\widehat{abc}\widetilde{def}$', r'$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$', - r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$' + r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$', + ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$' ] from pylab import * Modified: branches/transforms/examples/quadmesh_demo.py =================================================================== --- branches/transforms/examples/quadmesh_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/quadmesh_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -2,23 +2,26 @@ """ pcolormesh uses a QuadMesh, a faster generalization of pcolor, but with some restrictions. + +This demo illustrates a bug in quadmesh with masked data. """ -import numpy as nx -from pylab import figure,show +import numpy as npy +from matplotlib.pyplot import figure, show from matplotlib import cm, colors +from matplotlib.numerix import npyma as ma n = 56 -x = nx.linspace(-1.5,1.5,n) -X,Y = nx.meshgrid(x,x); -Qx = nx.cos(Y) - nx.cos(X) -Qz = nx.sin(Y) + nx.sin(X) +x = npy.linspace(-1.5,1.5,n) +X,Y = npy.meshgrid(x,x); +Qx = npy.cos(Y) - npy.cos(X) +Qz = npy.sin(Y) + npy.sin(X) Qx = (Qx + 1.1) -Z = nx.sqrt(X**2 + Y**2)/5; -Z = (Z - nx.amin(Z)) / (nx.amax(Z) - nx.amin(Z)) +Z = npy.sqrt(X**2 + Y**2)/5; +Z = (Z - Z.min()) / (Z.max() - Z.min()) # The color array can include masked values: -Zm = nx.ma.masked_where(nx.fabs(Qz) < 0.5*nx.amax(Qz), Z) +Zm = ma.masked_where(npy.fabs(Qz) < 0.5*npy.amax(Qz), Z) fig = figure() Modified: branches/transforms/examples/step_demo.py =================================================================== --- branches/transforms/examples/step_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/step_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,5 +1,6 @@ import numpy as npy -from pylab import * +from matplotlib.numerix import npyma as ma +from matplotlib.pyplot import step, legend, xlim, ylim, show x = npy.arange(1, 7, 0.4) y0 = npy.sin(x) @@ -13,7 +14,7 @@ y -= 0.5 step(x, y, where='post', label='post') -y = npy.ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) +y = ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) step(x,y, label='masked (pre)') legend() @@ -22,3 +23,4 @@ ylim(-0.5, 4) show() + Modified: branches/transforms/examples/units/bar_unit_demo.py =================================================================== --- branches/transforms/examples/units/bar_unit_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/units/bar_unit_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -4,15 +4,16 @@ N = 5 menMeans = (150*cm, 160*cm, 146*cm, 172*cm, 155*cm) -menStd = (20*cm, 30*cm, 32*cm, 10*cm, 20*cm) +menStd = ( 20*cm, 30*cm, 32*cm, 10*cm, 20*cm) fig = figure() ax = fig.add_subplot(111) ind = nx.arange(N) # the x locations for the groups -width = 0.35 # the width of the bars +width = 0.35 # the width of the bars p1 = ax.bar(ind, menMeans, width, color='r', bottom=0*cm, yerr=menStd) + womenMeans = (145*cm, 149*cm, 172*cm, 165*cm, 200*cm) womenStd = (30*cm, 25*cm, 20*cm, 31*cm, 22*cm) p2 = ax.bar(ind+width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd) Modified: branches/transforms/lib/matplotlib/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/__init__.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/__init__.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -234,12 +234,11 @@ def checkdep_ghostscript(): try: if sys.platform == 'win32': - command = 'gswin32c -v' + command = 'gswin32c --version' else: - command = 'gs -v' + command = 'gs --version' stdin, stdout = os.popen4(command) - line = stdout.readlines()[0] - v = line.split()[-2] + v = stdout.read()[:-1] vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1' float(vtest) return vtest Modified: branches/transforms/lib/matplotlib/_mathtext_data.py =================================================================== --- branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1753,7 +1753,10 @@ uni2type1 = dict([(v,k) for k,v in type12uni.items()]) -tex2uni = {'doteq': 8784, +tex2uni = { +'widehat': 0x0302, +'widetilde': 0x0303, +'doteq': 8784, 'partial': 8706, 'gg': 8811, 'asymp': 8781, @@ -1883,7 +1886,7 @@ 'measeq': 8798, 'upharpoonleft': 8639, 'lq': 8216, -'Upsilon': 978, +'Upsilon': 933, 'subsetneq': 8842, 'greater': 62, 'supsetneq': 8843, @@ -2236,7 +2239,7 @@ 'combiningbreve' : 774, 'combiningoverline' : 772, 'combininggraveaccent' : 768, -'combiningacuteaccent' : 714, +'combiningacuteaccent' : 769, 'combiningdiaeresis' : 776, 'combiningtilde' : 771, 'combiningrightarrowabove' : 8407, Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1638,25 +1638,33 @@ self.xaxis.set_scale(value, **kwargs) self._update_transScale() - def get_xticks(self): + def get_xticks(self, minor=False): 'Return the x ticks as a list of locations' - return self.xaxis.get_ticklocs() + return self.xaxis.get_ticklocs(minor=minor) - def set_xticks(self, ticks): + def set_xticks(self, ticks, minor=False): """ Set the x ticks with list of ticks ACCEPTS: sequence of floats """ - return self.xaxis.set_ticks(ticks) + return self.xaxis.set_ticks(ticks, minor=minor) - def get_xticklabels(self): + def get_xmajorticklabels(self): 'Get the xtick labels as a list of Text instances' - return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels()) + return cbook.silent_list('Text xticklabel', self.xaxis.get_majorticklabels()) - def set_xticklabels(self, labels, fontdict=None, **kwargs): + def get_xminorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text xticklabel', self.xaxis.get_minorticklabels()) + + def get_xticklabels(self, minor=False): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels(minor=minor)) + + def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ - SET_XTICKLABELS(labels, fontdict=None, **kwargs) + set_xticklabels(labels, fontdict=None, minor=False, **kwargs) Set the xtick labels with list of strings labels Return a list of axis text instances. @@ -1666,7 +1674,7 @@ ACCEPTS: sequence of strings """ - return self.xaxis.set_ticklabels(labels, fontdict, **kwargs) + return self.xaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) set_xticklabels.__doc__ = cbook.dedent(set_xticklabels.__doc__) % martist.kwdocd def invert_yaxis(self): @@ -1791,25 +1799,33 @@ self.yaxis.set_scale(value, **kwargs) self._update_transScale() - def get_yticks(self): + def get_yticks(self, minor=False): 'Return the y ticks as a list of locations' - return self.yaxis.get_ticklocs() + return self.yaxis.get_ticklocs(minor=minor) - def set_yticks(self, ticks): + def set_yticks(self, ticks, minor=False): """ Set the y ticks with list of ticks ACCEPTS: sequence of floats """ - return self.yaxis.set_ticks(ticks) + return self.yaxis.set_ticks(ticks, minor=minor) - def get_yticklabels(self): - 'Get the ytick labels as a list of Text instances' - return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels()) + def get_ymajorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_majorticklabels()) - def set_yticklabels(self, labels, fontdict=None, **kwargs): + def get_yminorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_minorticklabels()) + + def get_yticklabels(self, minor=False): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels(minor=minor)) + + def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ - SET_YTICKLABELS(labels, fontdict=None, **kwargs) + set_yticklabels(labels, fontdict=None, minor=False, **kwargs) Set the ytick labels with list of strings labels. Return a list of Text instances. @@ -1819,7 +1835,7 @@ ACCEPTS: sequence of strings """ - return self.yaxis.set_ticklabels(labels, fontdict, **kwargs) + return self.yaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) set_yticklabels.__doc__ = cbook.dedent(set_yticklabels.__doc__) % martist.kwdocd def xaxis_date(self, tz=None): @@ -3314,22 +3330,7 @@ patches = [] - # lets do some conversions now - if self.xaxis is not None: - xconv = self.xaxis.converter - if xconv is not None: - units = self.xaxis.get_units() - left = xconv.convert( left, units ) - width = xconv.convert( width, units ) - if self.yaxis is not None: - yconv = self.yaxis.converter - if yconv is not None : - units = self.yaxis.get_units() - bottom = yconv.convert( bottom, units ) - height = yconv.convert( height, units ) - - if align == 'edge': pass elif align == 'center': @@ -3590,7 +3591,7 @@ texts = [] slices = [] autotexts = [] - for frac, label, expl in zip(x,labels, explode): + for frac, label, expl in cbook.safezip(x,labels, explode): x, y = center theta2 = theta1 + frac thetam = 2*math.pi*0.5*(theta1+theta2) @@ -3717,23 +3718,24 @@ a list of error bar cap lines, the third element is a list of line collections for the horizontal and vertical error ranges """ + self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) if not self._hold: self.cla() - # make sure all the args are iterable arrays - if not iterable(x): x = npy.array([x]) - else: x = npy.asarray(x) + # make sure all the args are iterable; use lists not arrays to preserve units + if not iterable(x): + x = [x] - if not iterable(y): y = npy.array([y]) - else: y = npy.asarray(y) + if not iterable(y): + y = [y] if xerr is not None: - if not iterable(xerr): xerr = npy.array([xerr]) - else: xerr = npy.asarray(xerr) + if not iterable(xerr): + xerr = [xerr]*len(x) if yerr is not None: - if not iterable(yerr): yerr = npy.array([yerr]) - else: yerr = npy.asarray(yerr) + if not iterable(yerr): + yerr = [yerr]*len(y) l0 = None @@ -3749,7 +3751,9 @@ if 'lw' in kwargs: lines_kw['lw']=kwargs['lw'] - if not iterable(lolims): lolims = npy.array([lolims]*len(x), bool) + # arrays fine here, they are booleans and hence not units + if not iterable(lolims): + lolims = npy.asarray([lolims]*len(x), bool) else: lolims = npy.asarray(lolims, bool) if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool) @@ -3761,6 +3765,18 @@ if not iterable(xuplims): xuplims = npy.array([xuplims]*len(x), bool) else: xuplims = npy.asarray(xuplims, bool) + def xywhere(xs, ys, mask): + """ + return xs[mask], ys[mask] where mask is True but xs and + ys are not arrays + """ + assert len(xs)==len(ys) + assert len(xs)==len(mask) + xs = [thisx for thisx, b in zip(xs, mask) if b] + ys = [thisy for thisy, b in zip(ys, mask) if b] + return xs, ys + + if capsize > 0: plot_kw = { 'ms':2*capsize, @@ -3771,51 +3787,68 @@ plot_kw['mew']=kwargs['mew'] if xerr is not None: - if len(xerr.shape) == 1: - left = x-xerr - right = x+xerr + if iterable(xerr) and len(xerr)==2: + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[0])] + right = [thisx+thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[1])] else: - left = x-xerr[0] - right = x+xerr[1] + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in cbook.safezip(x,xerr)] + right = [thisx+thiserr for (thisx, thiserr) in cbook.safezip(x,xerr)] barcols.append( self.hlines(y, left, right, **lines_kw ) ) if capsize > 0: if xlolims.any(): - caplines.extend( self.plot(left[xlolims], y[xlolims], ls='None', marker=mlines.CARETLEFT, **plot_kw) ) + # can't use numpy logical indexing since left and + # y are lists + leftlo, ylo = xywhere(left, y, xlolims) + + caplines.extend( self.plot(leftlo, ylo, ls='None', marker=mlines.CARETLEFT, **plot_kw) ) xlolims = ~xlolims - caplines.extend( self.plot(left[xlolims], y[xlolims], 'k|', **plot_kw) ) + leftlo, ylo = xywhere(left, y, xlolims) + caplines.extend( self.plot(leftlo, ylo, 'k|', **plot_kw) ) else: caplines.extend( self.plot(left, y, 'k|', **plot_kw) ) if xuplims.any(): - caplines.extend( self.plot(right[xuplims], y[xuplims], ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) + + rightup, yup = xywhere(right, y, xuplims) + caplines.extend( self.plot(rightup, yup, ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) xuplims = ~xuplims - caplines.extend( self.plot(right[xuplims], y[xuplims], 'k|', **plot_kw) ) + rightup, yup = xywhere(right, y, xuplims) + caplines.extend( self.plot(rightup, yup, 'k|', **plot_kw) ) else: caplines.extend( self.plot(right, y, 'k|', **plot_kw) ) if yerr is not None: - if len(yerr.shape) == 1: - lower = y-yerr - upper = y+yerr + if iterable(yerr) and len(yerr)==2: + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[0])] + upper = [thisy+thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[1])] else: - lower = y-yerr[0] - upper = y+yerr[1] + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in cbook.safezip(y,yerr)] + upper = [thisy+thiserr for (thisy, thiserr) in cbook.safezip(y,yerr)] barcols.append( self.vlines(x, lower, upper, **lines_kw) ) if capsize > 0: if lolims.any(): - caplines.extend( self.plot(x[lolims], lower[lolims], ls='None', marker=mlines.CARETDOWN, **plot_kw) ) + xlo, lowerlo = xywhere(x, lower, lolims) + caplines.extend( self.plot(xlo, lowerlo, ls='None', marker=mlines.CARETDOWN, **plot_kw) ) lolims = ~lolims - caplines.extend( self.plot(x[lolims], lower[lolims], 'k_', **plot_kw) ) + xlo, lowerlo = xywhere(x, lower, lolims) + caplines.extend( self.plot(xlo, lowerlo, 'k_', **plot_kw) ) else: caplines.extend( self.plot(x, lower, 'k_', **plot_kw) ) if uplims.any(): - caplines.extend( self.plot(x[uplims], upper[uplims], ls='None', marker=mlines.CARETUP, **plot_kw) ) + xup, upperup = xywhere(x, upper, uplims) + + caplines.extend( self.plot(xup, upperup, ls='None', marker=mlines.CARETUP, **plot_kw) ) uplims = ~uplims - caplines.extend( self.plot(x[uplims], upper[uplims], 'k_', **plot_kw) ) + xup, upperup = xywhere(x, upper, uplims) + caplines.extend( self.plot(xup, upperup, 'k_', **plot_kw) ) else: caplines.extend( self.plot(x, upper, 'k_', **plot_kw) ) Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/axis.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -513,8 +513,8 @@ def get_children(self): children = [self.label] majorticks = self.get_major_ticks() - minorticks = self.get_minor_ticks() - + minorticks = self.get_minor_ticks() + children.extend(majorticks) children.extend(minorticks) return children @@ -669,24 +669,62 @@ 'Return the depth of the axis used by the picker' return self.pickradius - def get_ticklabels(self): - 'Return a list of Text instances for ticklabels' + def get_majorticklabels(self): + 'Return a list of Text instances for the major ticklabels' 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) + return silent_list('Text major ticklabel', labels1+labels2) - def get_ticklines(self): - 'Return the ticklines lines as a list of Line2D instance' + def get_minorticklabels(self): + 'Return a list of Text instances for the minor ticklabels' + ticks = self.get_minor_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 minor ticklabel', labels1+labels2) + + def get_ticklabels(self, minor=False): + 'Return a list of Text instances for ticklabels' + if minor: + return self.get_minorticklabels() + return self.get_majorticklabels() + + def get_majorticklines(self): + 'Return the major tick lines as a list of Line2D instances' lines = [] - ticks = self.get_major_ticks() + ticks = self.get_major_ticks() for tick in ticks: lines.append(tick.tick1line) lines.append(tick.tick2line) return silent_list('Line2D ticklines', lines) - def get_ticklocs(self): + def get_minorticklines(self): + 'Return the minor tick lines as a list of Line2D instances' + lines = [] + ticks = self.get_minor_ticks() + for tick in ticks: + lines.append(tick.tick1line) + lines.append(tick.tick2line) + return silent_list('Line2D ticklines', lines) + + def get_ticklines(self, minor=False): + 'Return the tick lines as a list of Line2D instances' + if minor: + return self.get_minorticklines() + return self.get_majorticklines() + + def get_majorticklocs(self): + "Get the major tick locations in data coordinates as a numpy array" + return self.major.locator() + + def get_minorticklocs(self): + "Get the minor tick locations in data coordinates as a numpy array" + return self.minor.locator() + + def get_ticklocs(self, minor=False): "Get the tick locations in data coordinates as a numpy array" + if minor: + return self.minor.locator() return self.major.locator() def _get_tick(self, major): @@ -728,7 +766,6 @@ 'get the tick instances; grow as necessary' if numticks is None: numticks = len(self.get_major_locator()()) - if len(self.majorTicks) < numticks: # update the new tick label properties from the old for i in range(numticks - len(self.majorTicks)): @@ -934,23 +971,30 @@ def set_ticklabels(self, ticklabels, *args, **kwargs): """ Set the text values of the tick labels. Return a list of Text - instances. + instances. Use kwarg minor=True to select minor ticks. ACCEPTS: sequence of strings """ #ticklabels = [str(l) for l in ticklabels] + minor = kwargs.pop('minor', False) + if minor: + self.set_minor_formatter(FixedFormatter(ticklabels)) + ticks = self.get_minor_ticks() + else: + self.set_major_formatter( FixedFormatter(ticklabels) ) + ticks = self.get_major_ticks() self.set_major_formatter( FixedFormatter(ticklabels) ) ret = [] - for i, tick in enumerate(self.get_major_ticks()): + for i, tick in enumerate(ticks): if i<len(ticklabels): tick.label1.set_text(ticklabels[i]) ret.append(tick.label1) tick.label1.update(kwargs) return ret - def set_ticks(self, ticks): + def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks @@ -958,10 +1002,14 @@ """ ### XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) - self.set_major_locator( FixedLocator(ticks) ) if len(ticks): self.set_view_interval(min(ticks), max(ticks)) - return self.get_major_ticks(len(ticks)) + if minor: + self.set_minor_locator(FixedLocator(ticks)) + return self.get_minor_ticks(len(ticks)) + else: + self.set_major_locator( FixedLocator(ticks) ) + return self.get_major_ticks(len(ticks)) def _update_label_position(self, bboxes, bboxes2): """ Modified: branches/transforms/lib/matplotlib/backends/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/backends/__init__.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/__init__.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -6,7 +6,7 @@ 'new_figure_manager', 'backend_version'] interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg', - 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] + 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg'] non_interactive_bk = ['Agg2', 'Agg', 'Cairo', 'EMF', 'GDK', 'Pdf', 'PS', 'SVG', 'Template'] all_backends = interactive_bk + non_interactive_bk @@ -50,7 +50,4 @@ return new_figure_manager, draw_if_interactive, show -# a hack to keep old versions of ipython working with mpl -if 'IPython.Shell' in sys.modules: - new_figure_manager, draw_if_interactive, show = pylab_setup() Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -9,6 +9,7 @@ import re import sys import time +import warnings import zlib import numpy as npy @@ -25,7 +26,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import Bunch, enumerate, is_string_like, reverse_dict, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM import matplotlib.type1font as type1font import matplotlib.dviread as dviread @@ -790,7 +791,8 @@ glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) # Why divided by 3.0 ??? Wish I knew... MGD widths.append((ccode, cvt(glyph.horiAdvance) / 3.0)) - cid_to_gid_map[ccode] = unichr(gind) + if ccode < 65536: + cid_to_gid_map[ccode] = unichr(gind) max_ccode = max(ccode, max_ccode) widths.sort() cid_to_gid_map = cid_to_gid_map[:max_ccode + 1] @@ -880,6 +882,15 @@ 'StemV' : 0 # ??? } + # The font subsetting to a Type 3 font does not work for + # OpenType (.otf) that embed a Postscript CFF font, so avoid that -- + # save as a (non-subsetted) Type 42 font instead. + if is_opentype_cff_font(filename): + fonttype = 42 + warnings.warn(("'%s' can not be subsetted into a Type 3 font. " + + "The entire font will be embedded in the output.") % + os.path.basename(filename)) + if fonttype == 3: return embedTTFType3(font, characters, descriptor) elif fonttype == 42: @@ -1130,10 +1141,6 @@ self.truetype_font_cache = {} self.afm_font_cache = {} self.file.used_characters = self.used_characters = {} - if rcParams['pdf.fonttype'] == 3: - self.encode_string = self.encode_string_type3 - else: - self.encode_string = self.encode_string_type42 self.mathtext_parser = MathTextParser("Pdf") self.image_magnification = dpi/72.0 self.tex_font_map = None @@ -1235,7 +1242,7 @@ # When using Type 3 fonts, we can't use character codes higher # than 255, so we use the "Do" command to render those # instead. - fonttype = rcParams['pdf.fonttype'] + global_fonttype = rcParams['pdf.fonttype'] # Set up a global transformation matrix for the whole math expression a = angle / 180.0 * pi @@ -1248,6 +1255,11 @@ prev_font = None, None oldx, oldy = 0, 0 for ox, oy, fontname, fontsize, num, symbol_name in glyphs: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + if fonttype == 42 or num <= 255: self._setup_textpos(ox, oy, 0, oldx, oldy) oldx, oldy = ox, oy @@ -1255,14 +1267,19 @@ self.file.output(self.file.fontName(fontname), fontsize, Op.selectfont) prev_font = fontname, fontsize - self.file.output(self.encode_string(unichr(num)), Op.show) + self.file.output(self.encode_string(unichr(num), fonttype), Op.show) self.file.output(Op.end_text) # If using Type 3 fonts, render all of the two-byte characters # as XObjects using the 'Do' command. - if fonttype == 3: + if global_fonttype == 3: for ox, oy, fontname, fontsize, num, symbol_name in glyphs: - if num > 255: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + + if fonttype == 3 and num > 255: self.file.output(Op.gsave, 0.001 * fontsize, 0, 0, 0.001 * fontsize, @@ -1362,10 +1379,9 @@ self.draw_polygon(boxgc, gc._rgb, ((x1,y1), (x2,y2), (x3,y3), (x4,y4))) - def encode_string_type3(self, s): - return s.encode('cp1252', 'replace') - - def encode_string_type42(self, s): + def encode_string(self, s, fonttype): + if fonttype == 3: + return s.encode('cp1252', 'replace') return s.encode('utf-16be', 'replace') def draw_text(self, gc, x, y, s, prop, angle, ismath=False): @@ -1391,20 +1407,29 @@ font = self._get_font_afm(prop) l, b, w, h = font.get_str_bbox(s) y -= b * fontsize / 1000 + fonttype = 42 else: font = self._get_font_ttf(prop) self.track_characters(font, s) font.set_text(s, 0.0, flags=LOAD_NO_HINTING) y += font.get_descent() / 64.0 + fonttype = rcParams['pdf.fonttype'] + + # We can't subset all OpenType fonts, so switch to Type 42 + # in that case. + if is_opentype_cff_font(font.fname): + fonttype = 42 + def check_simple_method(s): """Determine if we should use the simple or woven method - to output this text, and chunks the string into 1-bit and - 2-bit sections if necessary.""" + to output this text, and chunks the string into 1-byte and + 2-byte sections if necessary.""" use_simple_method = True chunks = [] - if rcParams['pdf.fonttype'] == 3: - if not isinstance(s, str) and len(s) != 0: + + if not rcParams['pdf.use14corefonts']: + if fonttype == 3 and not isinstance(s, str) and len(s) != 0: # Break the string into chunks where each chunk is either # a string of chars <= 255, or a single character > 255. s = unicode(s) @@ -1428,7 +1453,7 @@ prop.get_size_in_points(), Op.selectfont) self._setup_textpos(x, y, angle) - self.file.output(self.encode_string(s), Op.show, Op.end_text) + self.file.output(self.encode_string(s, fonttype), Op.show, Op.end_text) def draw_text_woven(chunks): """Outputs text using the woven method, alternating @@ -1458,7 +1483,7 @@ for chunk_type, chunk in chunks: if mode == 1 and chunk_type == 1: self._setup_textpos(newx, 0, 0, oldx, 0, 0) - self.file.output(self.encode_string(chunk), Op.show) + self.file.output(self.encode_string(chunk, fonttype), Op.show) oldx = newx lastgind = None Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -18,7 +18,7 @@ from matplotlib.cbook import is_string_like, izip, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING from matplotlib.ttconv import convert_ttf_to_ps from matplotlib.mathtext import MathTextParser @@ -846,7 +846,7 @@ else: self._print_figure(outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype) - + def _print_figure(self, outfile, format, dpi=72, facecolor='w', edgecolor='w', orientation='portrait', isLandscape=False, papertype=None): """ @@ -950,7 +950,15 @@ for c in chars: gind = cmap.get(ord(c)) or 0 glyph_ids.append(gind) - convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) + # The ttf to ps (subsetting) support doesn't work for + # OpenType fonts that are Postscript inside (like the + # STIX fonts). This will simply turn that off to avoid + # errors. + if is_opentype_cff_font(font_filename): + raise RuntimeError("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\nConsider using the Cairo backend.") + else: + fonttype = rcParams['ps.fonttype'] + convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) print >>fh, "end" print >>fh, "%%EndProlog" Modified: branches/transforms/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -6,8 +6,6 @@ import os, sys import matplotlib -from matplotlib import verbose -from matplotlib.cbook import enumerate from matplotlib.figure import Figure from backend_agg import FigureCanvasAgg @@ -61,7 +59,7 @@ self.drawRect = False self.rect = [] self.replot = True - self.pixmap = QtGui.QPixmap() + self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent) def resizeEvent( self, e ): FigureCanvasQT.resizeEvent( self, e ) @@ -86,26 +84,25 @@ # only replot data when needed if type(self.replot) is bool: # might be a bbox for blitting - if ( self.replot ): - #stringBuffer = str( self.buffer_rgba(0,0) ) - FigureCanvasAgg.draw( self ) + if self.replot: + FigureCanvasAgg.draw(self) - # matplotlib is in rgba byte order. - # qImage wants to put the bytes into argb format and - # is in a 4 byte unsigned int. little endian system is LSB first - # and expects the bytes in reverse order (bgra). - if ( QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian ): - stringBuffer = self.renderer._renderer.tostring_bgra() - else: - stringBuffer = self.renderer._renderer.tostring_argb() - qImage = QtGui.QImage( stringBuffer, self.renderer.width, - self.renderer.height, - QtGui.QImage.Format_ARGB32) - self.pixmap = self.pixmap.fromImage( qImage ) - p.drawPixmap( QtCore.QPoint( 0, 0 ), self.pixmap ) + # matplotlib is in rgba byte order. QImage wants to put the bytes + # into argb format and is in a 4 byte unsigned int. Little endian + # system is LSB first and expects the bytes in reverse order + # (bgra). + if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian: + stringBuffer = self.renderer._renderer.tostring_bgra() + else: + stringBuffer = self.renderer._renderer.tostring_argb() + qImage = QtGui.QImage(stringBuffer, self.renderer.width, + self.renderer.height, + QtGui.QImage.Format_ARGB32) + p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage)) + # draw the zoom rectangle to the QPainter - if ( self.drawRect ): + if self.drawRect: p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) ) p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] ) @@ -117,8 +114,8 @@ reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32) - self.pixmap = self.pixmap.fromImage( qImage ) - p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), self.pixmap) + pixmap = QtGui.QPixmap.fromImage(qImage) + p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap) p.end() self.replot = False Modified: branches/transforms/lib/matplotlib/cbook.py =================================================================== --- branches/transforms/lib/matplotlib/cbook.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/cbook.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -558,7 +558,7 @@ # expressions. However, this function accounted for almost 30% of # matplotlib startup time, so it is worthy of optimization at all # costs. - + if not s: # includes case of s is None return '' @@ -577,7 +577,7 @@ if unindent is None: unindent = re.compile("\n\r? {0,%d}" % nshift) _dedent_regex[nshift] = unindent - + result = unindent.sub("\n", s).strip() return result @@ -845,6 +845,15 @@ return mem +_safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d' +def safezip(*args): + 'make sure args are equal len before zipping' + Nx = len(args[0]) + for i, arg in enumerate(args[1:]): + if len(arg) != Nx: + raise ValueError(_safezip_msg % (Nx, i+1, len(arg))) + return zip(*args) + class MemoryMonitor: def __init__(self, nmax=20000): self._nmax = nmax Modified: branches/transforms/lib/matplotlib/config/checkdep.py =================================================================== --- branches/transforms/lib/matplotlib/config/checkdep.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/checkdep.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -4,28 +4,27 @@ import warnings import distutils.version as version +tex_req = '3.1415' +gs_req = '7.07' +gs_sugg = '8.60' +dvipng_req = '1.5' +pdftops_req = '3.0' + def dvipng(): try: stdin, stdout = os.popen4('dvipng -version') - line = stdout.readlines()[1] - v = line.split()[-1] - float(v) - return v + return stdout.readlines()[1].split()[-1] except (IndexError, ValueError): return None def ghostscript(): try: if sys.platform == 'win32': - command = 'gswin32c -v' + command = 'gswin32c --version' else: - command = 'gs -v' + command = 'gs --version' stdin, stdout = os.popen4(command) - line = stdout.readlines()[0] - v = line.split()[-2] - vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1' - float(vtest) - return vtest + return stdout.read()[:-1] except (IndexError, ValueError): return None @@ -35,9 +34,7 @@ line = stdout.readlines()[0] pattern = '3\.1\d+' match = re.search(pattern, line) - v = match.group(0) - float(v) - return v + return match.group(0) except (IndexError, ValueError): return None @@ -46,9 +43,7 @@ stdin, stdout = os.popen4('pdftops -v') for line in stdout.readlines(): if 'version' in line: - v = line.split()[-1] - float(v) - return v + return line.split()[-1] except (IndexError, ValueError): return None @@ -66,8 +61,6 @@ return False flag = True - gs_req = '7.07' - gs_sugg = '7.07' gs_v = ghostscript() if compare_versions(gs_v, gs_sugg): pass elif compare_versions(gs_v, gs_req): @@ -81,14 +74,13 @@ 'system.') % gs_req) if s == 'xpdf': - pdftops_req = '3.0' pdftops_v = pdftops() if compare_versions(pdftops_v, pdftops_req): pass else: flag = False warnings.warn(('matplotlibrc ps.usedistiller can not be set to ' - 'xpdf unless xpdf-%s or later is installed on your ' - 'system.') % pdftops_req) + 'xpdf unless pdftops-%s or later is installed on ' + 'your system.') % pdftops_req) if flag: return s @@ -99,10 +91,6 @@ if not s: return False - tex_req = '3.1415' - gs_req = '7.07' - gs_sugg = '7.07' - dvipng_req = '1.5' flag = True tex_v = tex() Deleted: branches/transforms/lib/matplotlib/config/configtest.py =================================================================== --- branches/transforms/lib/matplotlib/config/configtest.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/configtest.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,8 +0,0 @@ -from api import rcParams, mplConfig - -print 'loaded your old rcParams["backend"]:', rcParams['backend'] -print 'changing rcParams["backend"] to cairo' -rcParams["backend"] = 'cairo' -print 'mplConfig.backend.use is now :', mplConfig.backend.use -print 'changing rcParams["backend"] to BogusBackend:' -rcParams["backend"] = 'BogusBackend' Modified: branches/transforms/lib/matplotlib/config/cutils.py =================================================================== --- branches/transforms/lib/matplotlib/config/cutils.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/cutils.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -55,8 +55,6 @@ else: raise RuntimeError('please define environment variable $HOME') - - get_home = verbose.wrap('$HOME=%s', _get_home, always=False) def _get_configdir(): @@ -89,9 +87,9 @@ os.mkdir(p) return p + get_configdir = verbose.wrap('CONFIGDIR=%s', _get_configdir, always=False) - def _get_data_path(): 'get the path to matplotlib data' Modified: branches/transforms/lib/matplotlib/config/mplconfig.py =================================================================== --- branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -166,7 +166,7 @@ it = T.Trait('serif:oblique' , mplT.FontconfigPatternHandler()) bf = T.Trait('serif:bold' , mplT.FontconfigPatternHandler()) sf = T.Trait('sans' , mplT.FontconfigPatternHandler()) - use_cm = T.true + fontset = T.Trait('cm', 'cm', 'stix', 'custom') fallback_to_cm = T.true class axes(TConfig): @@ -344,7 +344,7 @@ 'mathtext.it' : (self.tconfig.mathtext, 'it'), 'mathtext.bf' : (self.tconfig.mathtext, 'bf'), 'mathtext.sf' : (self.tconfig.mathtext, 'sf'), - 'mathtext.use_cm' : (self.tconfig.mathtext, 'use_cm'), + 'mathtext.fontset' : (self.tconfig.mathtext, 'fontset'), 'mathtext.fallback_to_cm' : (self.tconfig.mathtext, 'fallback_to_cm'), 'image.aspect' : (self.tconfig.image, 'aspect'), Modified: branches/transforms/lib/matplotlib/config/rcsetup.py =================================================================== --- branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -203,6 +203,8 @@ parse_fontconfig_pattern(s) return s +validate_fontset = ValidateInStrings('fontset', ['cm', 'stix', 'custom']) + validate_verbose = ValidateInStrings('verbose',[ 'silent', 'helpful', 'debug', 'debug-annoying', ]) @@ -365,7 +367,7 @@ 'mathtext.it' : ['serif:italic', validate_font_properties], 'mathtext.bf' : ['serif:bold', validate_font_properties], 'mathtext.sf' : ['sans\-serif', validate_font_properties], - 'mathtext.use_cm' : [True, validate_bool], + 'mathtext.fontset' : ['cm', validate_fontset], 'mathtext.fallback_to_cm' : [True, validate_bool], 'image.aspect' : ['equal', validate_aspect], # equal, auto, a number Modified: branches/transforms/lib/matplotlib/contour.py =================================================================== --- branches/transforms/lib/matplotlib/contour.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/contour.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -395,7 +395,8 @@ self.levels = kwargs.get('levels', None) self.filled = kwargs.get('filled', False) self.linewidths = kwargs.get('linewidths', None) - + self.linestyles = kwargs.get('linestyles', 'solid') + self.alpha = kwargs.get('alpha', 1.0) self.origin = kwargs.get('origin', None) self.extent = kwargs.get('extent', None) @@ -406,6 +407,15 @@ self.antialiased = kwargs.get('antialiased', True) self.nchunk = kwargs.get('nchunk', 0) self.locator = kwargs.get('locator', None) + if (isinstance(norm, colors.LogNorm) + or isinstance(self.locator, ticker.LogLocator)): + self.logscale = True + if norm is None: + norm = colors.LogNorm() + if self.extend is not 'neither': + raise ValueError('extend kwarg does not work yet with log scale') + else: + self.logscale = False if self.origin is not None: assert(self.origin in ['lower', 'upper', 'image']) @@ -453,11 +463,13 @@ else: tlinewidths = self._process_linewidths() self.tlinewidths = tlinewidths + tlinestyles = self._process_linestyles() C = _cntr.Cntr(x, y... [truncated message content] |