Hello List,
I am trying to determine the position of the axes after an imshow and am having problems.
I get a different answer on my Mac (the correct answer) than Windows (the wrong answer).
I have a file called testimage.py with 5 lines:
from pylab import *
c = ones((10,20))
ax = imshow©
show()
print ax.get_axes().get_position()
I run this file from IPython.
On my Mac I get:
run testimage
Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
On Windows I get (the wrong answer):
run testimage
Bbox(array([[ 0.125, 0.1 ],
[0.9, 0.9 ]]))
Any thoughts? When I type the commands in at the IPython prompt it works most of the time (on Windows), but it never works when running the file. What in the world could be different?
mp version 1.1.0 on both systems.
Thanks for your help,
Mark
From: Mark Bakker [mailto:markbak@…287…]
Sent: Monday, July 30, 2012 05:54
Hello List,
I am trying to determine the position of the axes after an imshow and am having problems.
I get a different answer on my Mac (the correct answer) than Windows (the wrong answer).
[…]
Any thoughts? When I type the commands in at the IPython prompt it works most of the time (on Windows), but it never works when running the file. What in the world could be different?
mp version 1.1.0 on both systems.
Are you using the same backend on both systems?
Perhaps when you run the script within IPython on your Windows system, the show() call is not triggering a draw. You can force drawing by calling draw() before show(). I hope that helps.
I tried a few things and found out that doing a pause works.
So why does a pause work, but a draw() or show() does not?
This all on Windows using the standard PythonXY installation.
Here is the code that works (testimage.py):
from pylab import *
c = ones((10,20))
ax = imshow(c)
pause(0.01)
print ax.get_axes().get_position()
Running from IPython:
run testimage
Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
···
On Wed, Aug 1, 2012 at 8:56 PM, Stan West <stan.west@…706…> wrote:
From: Mark Bakker [mailto:markbak@…287… ]
Sent: Monday, July 30, 2012 05:54
Hello List,
I am trying to determine the position of the axes after an imshow and am having problems.
I get a different answer on my Mac (the correct answer) than Windows (the wrong answer).
[…]
Any thoughts? When I type the commands in at the IPython prompt it works most of the time (on Windows), but it never works when running the file. What in the world could be different?
mp version 1.1.0 on both systems.
Are you using the same backend on both systems?
Perhaps when you run the script within IPython on your Windows system, the show() call is not triggering a draw. You can force drawing by calling draw() before show(). I hope that helps.
From: Mark Bakker [mailto:markbak@…287…]
Sent: Tuesday, August 07, 2012 06:42
I tried a few things and found out that doing a pause works.
So why does a pause work, but a draw() or show() does not?
This all on Windows using the standard PythonXY installation.
Here is the code that works (testimage.py):
from pylab import *
c = ones((10,20))
ax = imshow(c)
pause(0.01)
print ax.get_axes().get_position()
Running from IPython:
run testimage
Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
I modified your script to test show(), draw(), and pause(); it’s attached. For the WXAgg matplotlib backend, I get:
In [1]: print(matplotlib.get_backend())
WXAgg
In [2]: %run testimage
show: Bbox(array([[ 0.125, 0.1 ],
[ 0.9 , 0.9 ]]))
draw: Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
pause: Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
but for the Qt4Agg backend, I get:
In [1]: print(matplotlib.get_backend())
Qt4Agg
In [2]: %run testimage
show: Bbox(array([[ 0.125, 0.1 ],
[ 0.9 , 0.9 ]]))
draw: Bbox(array([[ 0.125, 0.1 ],
[ 0.9 , 0.9 ]]))
pause: Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
Which backend have you been using?
testimage.py (279 Bytes)
I am glad to see you can reproduce the error, Stan.
I am running whatever is default with a PythonXY installation (sorry my windows machine is at work).
Strange behavior.
The code works fine on my mac (PyQt4 backend) with all options (show,draw,pause).
Should we file a bug report?
Mark
···
On Thu, Aug 9, 2012 at 4:02 PM, Stan West <stan.west@…706…> wrote:
From: Mark Bakker [mailto:markbak@…287… ]
Sent: Tuesday, August 07, 2012 06:42
I tried a few things and found out that doing a pause works.
So why does a pause work, but a draw() or show() does not?
This all on Windows using the standard PythonXY installation.
Here is the code that works (testimage.py):
from pylab import *
c = ones((10,20))
ax = imshow(c)
pause(0.01)
print ax.get_axes().get_position()
Running from IPython:
run testimage
Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
I modified your script to test show(), draw(), and pause(); it’s attached. For the WXAgg matplotlib backend, I get:
In [1]: print(matplotlib.get_backend())
WXAgg
In [2]: %run testimage
show: Bbox(array([[ 0.125, 0.1 ],
[ 0.9 , 0.9 ]]))
draw: Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
pause: Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
but for the Qt4Agg backend, I get:
In [1]: print(matplotlib.get_backend())
Qt4Agg
In [2]: %run testimage
show: Bbox(array([[ 0.125, 0.1 ],
[ 0.9 , 0.9 ]]))
draw: Bbox(array([[ 0.125, 0.1 ],
[ 0.9 , 0.9 ]]))
pause: Bbox(array([[ 0.125 , 0.24166667],
[ 0.9 , 0.75833333]]))
Which backend have you been using?
From: Mark Bakker [mailto:markbak@…83…287…]
Sent: Thursday, August 09, 2012 14:43
I am glad to see you can reproduce the error, Stan.
I am running whatever is default with a PythonXY installation (sorry my windows machine is at work).
Strange behavior.
The code works fine on my mac (PyQt4 backend) with all options (show,draw,pause).
Should we file a bug report?
Mark
I’d say that it’s your call, but what you found does seem appropriate for a bug report.