I would like to ensure that the axes on a plot I'm making are square
in the sense of how the axes appear in the figure. I tried using
ax.set_aspect(1) , but that squares the axes in data coordinates,
rather than in figure coordinates. So aside from generating a figure
that is always square (which doesn't always work anyway if, for
example, I want a colorbar), how can I force the axes to be a
particular axis ratio in coordinates of physical size on the page?
Adjusting a physical size of the axes is a bit tricky in matplotlib,
as the axes has an fixed position in normalized figure coordinate.
But, I guess setting the axes aspect ratio in physical size is doable
relatively easily, at least if your x,y axis are in linear scales. For
example, if you want a square axes, set the aspect as the inverse of
your data aspect (ratio).
ax.set_aspect(1./ax.get_data_ratio())
As you see, you need to reset the aspect whenever your data limit changes.
IHTH,
-JJ
ยทยทยท
On Wed, Sep 17, 2008 at 2:41 PM, Erik Tollerud <erik.tollerud@...287...> wrote:
I would like to ensure that the axes on a plot I'm making are square
in the sense of how the axes appear in the figure. I tried using
ax.set_aspect(1) , but that squares the axes in data coordinates,
rather than in figure coordinates. So aside from generating a figure
that is always square (which doesn't always work anyway if, for
example, I want a colorbar), how can I force the axes to be a
particular axis ratio in coordinates of physical size on the page?-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options