thanks Eric! Could you provide me with an executive summary as to pcolorfast vs imshow? Is it essentially a matter of speed? Also, I tried to add a colorbar but failed. What is the correct invocation? thanks a gain, Johann
Eric Firing wrote: > Johann Cohen-Tanugi wrote: >> thanks Johan, >> I posted to scipy because of histogram2d being in numpy, sorry about >> that. >> Now the stupid question, why can't imshow directly parse histogram2d, >> without the transitory extent object? > > imshow is a general image display function; it would not make sense to > customize it to match histogram2d. > > You may want to use Axes.pcolorfast instead. Example using ipython > -pylab: > > In [1]:import numpy as np > > In [2]:x, y = np.random.randn(2, 100000) > > In [3]:H, xedges, yedges = np.histogram2d(x, y, bins=50) > > In [4]:fig = figure() > > In [5]:ax = fig.add_subplot(111) > > In [6]:ax.pcolorfast? > > In [7]:ax.pcolorfast(xedges, yedges, H) > Out[7]:<matplotlib.image.AxesImage object at 0x8bf0ecc> > > In [8]:draw() > > Eric > >> Anyway, I am happy that there is a simple way as explained below! >> >> thanks again, >> Johann >> >> John Hunter wrote: >>> On Fri, Sep 5, 2008 at 10:36 AM, Johann Cohen-Tanugi >>> <[EMAIL PROTECTED]> wrote: >>> >>>> hi, I hope someone can quickly point me to some doc. >>>> I can do imshow(histogram2d(x,y)[0]) but then I miss the x and y >>>> binning >>>> correct labels. >>>> If I do imshow(histogram2d(x,y)) I get: >>>> ERROR: An unexpected error occurred while tokenizing input >>>> The following traceback may be corrupted or invalid >>>> The error message is: ('EOF in multi-line statement', (115, 0)) >>>> >>> matplotlib questions are best addressed to the matplotlib-users >>> mailing list at >>> >>> http://lists.sourceforge.net/mailman/listinfo/matplotlib-users >>> >>> histogram2d returns H, xedges and yedges. The first argument should >>> be passed to imshow, and the second two can be used to get the extents >>> >>> In [26]: x, y = np.random.randn(2, 100000) >>> >>> In [27]: H, xedges, yedges = np.histogram2d(x, y, bins=50) >>> >>> In [28]: extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] >>> >>> In [29]: imshow(H, extent=extent) >>> Out[29]: <matplotlib.image.AxesImage object at 0x9377bcc> >>> ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users