|
From: Moore, E. (NIH/N. [F] <eri...@ni...> - 2012-09-21 13:47:33
|
> -----Original Message-----
> From: Andrea Gavana [mailto:and...@gm...]
> Sent: Wednesday, September 19, 2012 11:09 AM
> To: mat...@li...
> Subject: [Matplotlib-users] Image as marker and axes "equal" aspect
> ratio
>
> Hi All,
>
> I am currently trying to plot 4 points (but they will be more, in
> an animated sequence later), and I am trying to use an image as a point
> marker. I am using the axes transData transform to get the point
> coordinates from the data world to the display world.
>
> Everything seems to be working OK (i.e., the images are placed
> correctly close to the plot points); however, as soon as I try to force
> the axes into an "equal" aspect ratio with this command:
>
> ax.set_aspect('equal')
>
> Then all the calculations are messed up and the images end up very far
> from the plot points. I have tried also the approach mentioned in this
> StackOverflow post:
>
> http://stackoverflow.com/questions/2318288/how-to-use-custom-marker-
> with-plot
>
> But I get the same wrong answer when I set the "equal" aspect ratio for
> the axes.
>
> I am attaching a small sample application which demonstrates the
> problem, a small "smiley.png" image needed to run the script and two
> plots generated by my script, one with the "equal" aspect ratio and the
> other without.
>
> I appreciate any suggestion, as I feel I am missing something
> important...
>
> Thank you in advance.
>
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against Reality."
> http://xoomer.alice.it/infinity77/
>
> # ------------------------------------------------------------- # def
> ask_mailing_list_support(email):
>
> if mention_platform_and_version() and include_sample_app():
> send_message(email)
> else:
> install_malware()
> erase_hard_drives()
> # ------------------------------------------------------------- #
Andrea,
The source of the problem is that the transformation you are using has not been updated to account for your set_aspect call. I played around a little bit, but I'm not sure how to force mpl to update the transform. Perhaps someone else can comment. This is a very fragile way to do things anyway because figimage places the image in screen coordinates and you really would like to place it relative to the axis.
Eric
|