errorbar and legend

Hello,

I did probably something not good but it seems for me that the legend() function is not working properly (at least with errorbar)

x = arange(0,1.0,0.01)
p1 = errorbar(x,x,x,fmt='o') # or errorbar(x,x,x,fmt='o')
legend()

it seems to put in the legend all the points and lines.

I tried to do a

legend((p1),('p1'))

but it's not working, you have to do:

legend((p1,),('p1',))

to obtain the legend. Perhaps that must be indicate in the documentation that a you need a tuple and the method to have a legend with errorbar.

Thanks,

N.

Hi,

I've been giving matplotlib (0.85) a spin, as a front end for 'exploring' scientific simulation results. Now I've got the data in and had a play, there's been a few things which have confused me somewhat about the API/features:

* One of the most obvious obstacles at the moment is that I'm plotting surface plots, using contour[f] primarily, and haven't found an obvious way of removing 'previous' results from axes. Should this work with 'gca().hold(False)' or equivalent? It doesn't seem to. As such I'm currently deleting and recreating the axes each time I change the data. While this is not great, it is faster than not doing so, since otherwise the graph accumulates contours and increasingly takes long to redraw. I suppose I'm asking whether there is the equivalent of [axes].set_ydata(), but for contours :slight_smile:

* Previously I've been using gnuplot to create pngs, which I can then form into a time series, mostly just plotting the data as a 'matrix'. While I take it for granted that python/matplotlib are loading/plotting the data in 'real-time' compared to just flicking between gnuplot-generated png's, pcolor is rather slow for me, and I'm unsure exactly what the other approaches (eg. imshow?) are targeted towards, or when they are appropriate compared to pcolor. However, not only is pcolor slow, but for some reason it defaults to automatically selecting a different (overly large) automatic axis-range than contour[f].

* For some reason my install leaves me with pylab windows which have no proper icons in the bottom button bar. I've set MATPLOTLIBDATA and PYTHONPATH, since I installed the modules into a subdir of my home directory.

* Closing the pylab windows using the window-manager results in the python process continuing - should this be calling some function to interrupt the show() function? (I'm running GTK/GTKAgg if its relevant)

Nevertheless, given these annoyances, I'm quite happy with the results so far - it is perhaps already simpler than the system I had been using previously, and has taken very little time to get to grips with :slight_smile:
Having said that, I'm not entirely clear whether pylab is intended to be 'the' interface to matplotlib, or just a simplified front-end - it seems quite confusing from reading some of the online documents.

Thanks for matplotlib, (I'll think of other things to ask, in time!)

* One of the most obvious obstacles at the moment is that I'm plotting surface plots, using contour[f] primarily, and haven't found an obvious way of removing 'previous' results from axes.

Axes objects have a cla() method which clears their contents. In pylab, I believe the function cla() clears the current axes.

* Previously I've been using gnuplot to create pngs, which I can then form into a time series, mostly just plotting the data as a 'matrix'. While I take it for granted that python/matplotlib are loading/plotting the data in 'real-time' compared to just flicking between gnuplot-generated png's, pcolor is rather slow for me, and I'm unsure exactly what the other approaches (eg. imshow?) are targeted towards, or when they are appropriate compared to pcolor.

pcolor() does a lot of work under the hood to plot things the way it does. imshow() gives you a pseudocolor plot that treats the elements of the matrix as luminescence, which may be exactly what you want. Check out the "pcolor_demo.py" example (which actually uses imshow()!):

  http://matplotlib.sourceforge.net/screenshots/pcolor_demo.py

However, not only is pcolor slow, but for some reason it defaults to automatically selecting a different (overly large) automatic axis-range than contour[f].

It's my understanding that this behavior is by design: pcolor() treats each element Z[i,j] as being in between in between the corresponding X and Y elements (e.g. between X[i,j] and X[i+1,j]). I'm far from certain about this, so please take my answer with a grain of salt.

* Closing the pylab windows using the window-manager results in the python process continuing - should this be calling some function to interrupt the show() function? (I'm running GTK/GTKAgg if its relevant)

I'm a bit confused as to what behavior you are seeing. Does show() return so your script can resume executing when you close the pylab window, or does it never block in the first place?

Having said that, I'm not entirely clear whether pylab is intended to be 'the' interface to matplotlib, or just a simplified front-end - it seems quite confusing from reading some of the online documents.

iPython+pylab appears to be "the" interface to matplotlib for Matlab-style interactive plotting. Pylab on its own is pretty good for quick 'n dirty plotting from scripts (e.g. visualizing the results of some algorithm as you debug and refine it).

Matplotlib also has an object-oriented API that is much better to use when you are embedding matplotlib plots in other python applications. The OO API is "the" interface to matplotlib in that it *is* matplotlib... pylab is a wrapper that manages a lot of details to make things more convenient.

Ken

ยทยทยท

On Dec 8, 2005, at 6:55 PM, Neil Pilgrim wrote: