Hmm. Is it possible that this hasn't propagated to public CVS yet? I just updated, and this is what I get:
···
---------------------------------------------------------------------------
exceptions.ValueError Traceback (most recent call last)
/home/fperez/research/code/mwadap/<console>
/usr/lib/python2.3/site-packages/matplotlib/pylab.py in set(h, *args, **kwargs)
1230 raise RuntimeError(msg)
1231
-> 1232 draw_if_interactive()
1233 return [x for x in flatten(ret)]
1234
/usr/local/home/fperez/code/python/IPython/genutils.py in wrapper(*args, **kw)
/usr/lib/python2.3/site-packages/matplotlib/backends/__init__.py in draw_if_interactive()
40 def draw_if_interactive():
41 draw_if_interactive._called = True
---> 42 __draw_int()
43 # Flag to store state, so external callers (like ipython) can keep track
44 # of draw calls.
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_tkagg.py in draw_if_interactive()
56 figManager = Gcf.get_active()
57 if figManager is not None:
---> 58 figManager.show()
59
60
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_tkagg.py in show(self)
276 # anim.py requires this
277 if sys.platform=='win32' : self.window.update()
--> 278 else: self.canvas.draw()
279 self._shown = True
280
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_tkagg.py in draw(self)
141
142 def draw(self):
--> 143 FigureCanvasAgg.draw(self)
144 tkagg.blit(self._tkphoto, self.renderer._renderer, 2)
145 self._master.update_idletasks()
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_agg.py in draw(self)
310 self.renderer = RendererAgg(w, h, self.figure.dpi)
311 self._lastKey = key
--> 312 self.figure.draw(self.renderer)
313
314 def tostring_rgb(self):
/usr/lib/python2.3/site-packages/matplotlib/figure.py in draw(self, renderer)
336
337 # render the axes
--> 338 for a in self.axes: a.draw(renderer)
339
340 # render the figure text
/usr/lib/python2.3/site-packages/matplotlib/axes.py in draw(self, renderer)
1480 if not self.get_visible(): return
1481 renderer.open_group('axes')
-> 1482 self.transData.freeze() # eval the lazy objects
1483 self.transAxes.freeze() # eval the lazy objects
1484 if self.axison:
ValueError: Cannot take log of nonpositive value
Note that I'm running straight off the CVS directory, because the RPM rebuild/reinstall takes too long for permanent testing. What I did was just to manually copy the .so files back into the CVS dir, renamed /usr/lib/python2.3/site-packages/matplotlib to .ori, and made a symlink:
planck[site-packages]> d matplotlib
/usr/lib/python2.3/site-packages
lrwxrwxrwx 1 root 51 Feb 4 11:18 matplotlib -> /usr/local/installers/src/matplotlib/lib/matplotlib/
This seems to work OK (I checked with a few print statements that I am indeed running off the CVS matplotlib/ dir). Since the most recent CVS update doesn't seem to change any C++ code, this should be OK, no?
I'm seeing further weirdness with log plots. Try this:
semilogy(frange(.1,1,npts=20),frange(0.1,1,npts=20))
semilogy(frange(.1,1,npts=20),frange(0.0,1,npts=20))
semilogy(frange(.1,1,npts=20),frange(0.1,1,npts=20))
Not only does the second one crash, but then, the third line (identical to the first) also crashes. Something is left in an internally inconsistent state, and essentially all log plots become impossible afterwards. The only solution is to restart pylab altogether.
If you have data points really close to 0, eg
1 >>> x = arange(-2.00, 10, 0.01)
2 >>> amin(abs(x))
Out[2]: 4.163336342344337e-17
You may a heavy performance price because so many decades are plotted,
each with minor ticks, and ticks are expensive in the current impl.
I am also implementing some default keypress events on the pylab
figure manager canvas. Eg 'g' to toggle grid mode.
I would like a key binding for toggling log/linear scale for x and y
independently. 'x' and 'y' are not good choices since they are
overloaded with constraining axes in interactive pan/zoom with the
toolbar. Suggestions? '1' and '2'? CTRL-x and and CTRL-y? 'l' and
'L'?
I like 'l'/'L' for gnuplot consistency. Note that their implementation is a bit funky though: 'l' toggles y-axis log (the most common case), while 'L' toggles log on the axis closest to the mouse pointer. I'll leave it up to you to decide whether you like this mouse-proximity thing or not. But 'l' for y-log, which is probably the most common type of log plot, I think is nice.
Are there other keybindings people would like to see implemented in
the default pylab figures?
'r' for the ruler thingie?
Best,
f