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?
Many thanks in advance!
Regards, Yoshi
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
···
On Thu, Sep 26, 2013 at 10:37 AM, Yoshi Rokuko <yoshi@...3676...> wrote:
Many thanks in advance!
Regards, Yoshi
Sun, 6 Oct 2013 15:41:07 -0500 Tony Yu <tsyu80@...287...>:
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?
works like a charm - thank you!
best regards,
Yoshi