[Matplotlib-users] colorbar, ax.get_position after figsize changed by ax.set_aspect

2006-10-05 Thread George Nurser
I have been trying to
i. plot a figure using pcolormesh
ii. set the proportions of the figure using ax.set_aspect
iii. draw colorbar

Problem is, colorbar height uses whole of axes box, not just height of
figure (whose proportions were set by call of
ax.set_aspect(aspect=2.,adjustable='box')).

I can't set the colorbar height manually either, as I don't know how
to get out the bounding box of the figure -- ax.get_position() just
gives the full axes box, which is unaffected by ax.set_aspect.

Is there any way of recovering the actual bounding box of the figure?
The docstring for the method ax.set_position says:

There are two position variables: one which is ultimately
used, but which may be modified by apply_aspect, and a second
which is the starting point for apply_aspect.

which = 'active' to change the first;
'original' to change the second;
'both' to change both

which sounds relevant, but these variables don't seem to apply to
ax.get_position()


--George Nurser.

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, ax.get_position after figsize changed by ax.set_aspect

2006-10-05 Thread Eric Firing
George Nurser wrote:
 I have been trying to
 i. plot a figure using pcolormesh
 ii. set the proportions of the figure using ax.set_aspect
 iii. draw colorbar
 
 Problem is, colorbar height uses whole of axes box, not just height of
 figure (whose proportions were set by call of
 ax.set_aspect(aspect=2.,adjustable='box')).
 
 I can't set the colorbar height manually either, as I don't know how
 to get out the bounding box of the figure -- ax.get_position() just
 gives the full axes box, which is unaffected by ax.set_aspect.
 
 Is there any way of recovering the actual bounding box of the figure?
 The docstring for the method ax.set_position says:
 
 There are two position variables: one which is ultimately
 used, but which may be modified by apply_aspect, and a second
 which is the starting point for apply_aspect.
 
 which = 'active' to change the first;
 'original' to change the second;
 'both' to change both
 
 which sounds relevant, but these variables don't seem to apply to
 ax.get_position()

George,

The problem with your attempt to use get_position() is that the aspect 
ratio does not affect the position until the apply_aspect method of the 
axes is called, which is normally when drawing occurs.  You can either 
call it yourself, or you can insert a draw command.  Here is an example 
of the first:

In [6]:pcolor(z)
Out[6]:matplotlib.collections.PolyCollection instance at 0xb3db690c

In [7]:gca().get_position()
Out[7]:[0.125, 0.099978, 0.77502, 
0.80004]

In [8]:gca().set_aspect(3)

In [9]:gca().get_position()
Out[9]:[0.125, 0.099978, 0.77502, 
0.80004]

In [10]:clf()

In [11]:pcolor(z)
Out[11]:matplotlib.collections.PolyCollection instance at 0xb3dc6a6c

In [12]:gca().get_position()
Out[12]:[0.125, 0.099978, 0.77502, 
0.80004]

In [13]:gca().set_aspect(3)

In [14]:gca().apply_aspect()

In [15]:gca().get_position()
Out[15]:
[0.31343312597200623,
  0.099978,
  0.39813374805598761,
  0.80004]

Eric

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users