GridSpec has unecpected effect

Hi,

In the following script, it seems to me,
that GridSpec does not work as expected.

···

----------------------------------------
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# adapted from http://matplotlib.sourceforge.net/users/gridspec.html

import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec

fig = plt.figure()

gs1 = GridSpec(3,3)
gs1.update( left=0.10, right=0.45 )
ax1 = fig.add_subplot( gs1[ 0:1, 0:1 ] )
ax1.set_position( [0.1, 0.1, 0.2, 0.8] )

gs2 = GridSpec(3,3)
gs2.update( left=0.55, right=0.95 )
ax2 = fig.add_subplot( gs2[ 1:3, 1:3 ] )
ax2.set_position( [0.5, 0.1, 0.2, 0.8] )

plt.show()
----------------------------------------

First I put an Axes ax1 with gs1.
For some reason, I want to adjust ax1 with ax1.set_position.
(In the real application only fine adjust)
If I run the script only to this point it works as expected.

Next I put another Axes ax2 with a new GridSpec gs2.
With the command gs2.update() the Axes ax1 will be put back
to the place where it would be without ax1.set_position().

Is this behavior to be explained?

Thanks
--
Kurt Mueller

Thanks for reporting this.
I opened a pull request that I believe fixes this problem.

Please test this if you can.

Depending on your need, you may work around this by calling all the
set_position method always after all the GridSpec.update call.

Regards,

-JJ

···

On Sat, Sep 17, 2011 at 1:37 AM, Kurt Mueller <kurt.alfred.mueller@...287...> wrote:

Hi,

In the following script, it seems to me,
that GridSpec does not work as expected.
----------------------------------------
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# adapted from http://matplotlib.sourceforge.net/users/gridspec.html

import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec

fig = plt.figure()

gs1 = GridSpec(3,3)
gs1.update( left=0.10, right=0.45 )
ax1 = fig.add_subplot( gs1[ 0:1, 0:1 ] )
ax1.set_position( [0.1, 0.1, 0.2, 0.8] )

gs2 = GridSpec(3,3)
gs2.update( left=0.55, right=0.95 )
ax2 = fig.add_subplot( gs2[ 1:3, 1:3 ] )
ax2.set_position( [0.5, 0.1, 0.2, 0.8] )

plt.show()
----------------------------------------

First I put an Axes ax1 with gs1.
For some reason, I want to adjust ax1 with ax1.set_position.
(In the real application only fine adjust)
If I run the script only to this point it works as expected.

Next I put another Axes ax2 with a new GridSpec gs2.
With the command gs2.update() the Axes ax1 will be put back
to the place where it would be without ax1.set_position().

Is this behavior to be explained?

Thanks
--
Kurt Mueller

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks for reporting this.
I opened a pull request that I believe fixes this problem.
fix GridSpec.update to update axes position only for axes assocaited with the gridspec instance. by leejjoon · Pull Request #472 · matplotlib/matplotlib · GitHub

Thank you very much!

Please test this if you can.

I hope next week.

Depending on your need, you may work around this by calling all the
set_position method always after all the GridSpec.update call.

Thanks, yes this will work for me.

···

Am 17.09.2011 um 15:38 schrieb Jae-Joon Lee:
--
kurt.alfred.mueller@...287...

Thanks for reporting this.
I opened a pull request that I believe fixes this problem.
fix GridSpec.update to update axes position only for axes assocaited with the gridspec instance. by leejjoon · Pull Request #472 · matplotlib/matplotlib · GitHub

Thank you very much!

Please test this if you can.

I hope next week.

I did a brief test.
(I added the three "if ax. ..." to the file gridspec.py in the matplotlib library.)
(matplotlib 1.0.1)
As far as I can tell is, that the unexpected effect did not occur any more.
I did not test it with shared axis.

Depending on your need, you may work around this by calling all the
set_position method always after all the GridSpec.update call.

In my programs I will use this approach until we move to a more recent matplotlib version.

Thanks

···

Am 17.09.2011 18:49, schrieb Kurt Mueller:

Am 17.09.2011 um 15:38 schrieb Jae-Joon Lee:

--
Kurt Mueller