I'm plotting some grid data using pcolor, and trying to get canvas pixel locations of data points using the
ax.transData.xy_tup()
method. I am saving these figures to PNG files using the default Agg backend. When I open these images up in Gimp and check the pixel locations, the X pixel locations are accurate, but the Y pixel locations I am getting from matplotlib seem to be exaggerated the further away from Y=0 I go. Am I using this method incorrectly? Could this be an artifact of the rendering to PNG?
Thanks,
Rich
Rich Fought wrote:
I'm plotting some grid data using pcolor, and trying to get canvas pixel locations of data points using the
ax.transData.xy_tup()
method. I am saving these figures to PNG files using the default Agg backend. When I open these images up in Gimp and check the pixel locations, the X pixel locations are accurate, but the Y pixel locations I am getting from matplotlib seem to be exaggerated the further away from Y=0 I go. Am I using this method incorrectly? Could this be an artifact of the rendering to PNG?
I determined what is causing the exaggerated y-pixel values. I was using
axes().set_aspect('equal')
on the figure and this apparently does not get taken into account when using
ax.transData.xy_tup()
I tried setting the aspect in the original fig.add_subplot, but got the same incorrect results.
ax = fig.add_subplot(111, aspect='equal')
Leaving the aspect alone gives correct pixel results.
Is this a bug, or expected behavior?
Rich
Rich,
The transforms can be modified at drawing time, so you need to get the pixel locations after the plot has been drawn. Are you doing this?
Eric
Rich Fought wrote:
ยทยทยท
Rich Fought wrote:
I'm plotting some grid data using pcolor, and trying to get canvas pixel locations of data points using the
ax.transData.xy_tup()
method. I am saving these figures to PNG files using the default Agg backend. When I open these images up in Gimp and check the pixel locations, the X pixel locations are accurate, but the Y pixel locations I am getting from matplotlib seem to be exaggerated the further away from Y=0 I go. Am I using this method incorrectly? Could this be an artifact of the rendering to PNG?
I determined what is causing the exaggerated y-pixel values. I was using
axes().set_aspect('equal')
on the figure and this apparently does not get taken into account when using
ax.transData.xy_tup()
I tried setting the aspect in the original fig.add_subplot, but got the same incorrect results.
ax = fig.add_subplot(111, aspect='equal')
Leaving the aspect alone gives correct pixel results.
Is this a bug, or expected behavior?
Rich
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
Eric Firing wrote:
The transforms can be modified at drawing time, so you need to get the pixel locations after the plot has been drawn. Are you doing this?
Eric,
Thank you! I put the transforms after savefig() and it works like a champ now.
Rich