|
From: Tony Yu <ts...@gm...> - 2013-10-06 20:41:54
|
On Thu, Sep 26, 2013 at 10:37 AM, Yoshi Rokuko <yo...@ro...> wrote:
> Hey,
>
> I'm trying to plot streamplots into an axesgrid object with something
> like:
>
> fig = pl.figure(1, (13, 20))
> grid = AxesGrid(fig, 111,
> nrows_ncols = (3, 2),
> axes_pad = 0.6,
> cbar_location = 'top',
> cbar_mode = 'each',
> cbar_size = '2%',
> cbar_pad = '1%',
> )
> [...]
> norm = mpl.colors.LogNorm(vmin=1, vmax=5000)
> im = grid[i].streamplot(XPTS, YPTS, zx, zy,
> color=zr,
> arrowsize=.001,
> norm=norm)
> grid.cbar_axes[i].colorbar(im)
> [...]
>
> and then it failes with:
>
> Traceback (most recent call last):
> File "./results.py", line 96, in <module>
> grid.cbar_axes[i].colorbar(im)
> File
> "/usr/lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_grid.py",
> line 85, in colorbar cb = Colorbar(self, mappable,
> orientation=orientation, **kwargs) File
> "/usr/lib/python2.7/site-packages/mpl_toolkits/axes_grid1/colorbar.py",
> line 706, in __init__ mappable.autoscale_None() # Ensure
> mappable.norm.vmin, vmax AttributeError: 'StreamplotSet' object has no
> attribute 'autoscale_None'
>
> can't I use streamplots in axesgrid? If I comment out the colorbar for
> the streamplot colors it works ...
> Is this a bug? Is there a right way to do it? Is there a work around?
>
Hi Yoshi,
The return value for streamplot is a bit hacked together. Its just a simple
object containing a line collection and an arrow collection. Instead of
passing the set of collections, just pass one of the collections to the
colorbar. For example:
sset = grid[i].streamplot(XPTS, YPTS, zx, zy, color=zr)
grid.cbar_axes[i].colorbar(sset.lines)
Does that work for you?
Best,
-Tony
>
> Many thanks in advance!
>
> Regards, Yoshi
|