Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Square plots #3742

Closed
holocronweaver opened this issue Oct 30, 2014 · 5 comments
Closed

Square plots #3742

holocronweaver opened this issue Oct 30, 2014 · 5 comments
Milestone

Comments

@holocronweaver
Copy link

When using pyplot, I can use axis('equal') to make the axes have the same scale (a circle is a circle). However, this leaves a hole for the common case of comparing experiment with theory where a square plot is desired (i.e., the axes should have the same limits).

To achieve this, I typically write a function:

def equalAxisLimits(ax):
    '''
    Make both axes have the same range. Useful for producing square plots.
    '''
    xlim = ax.get_xlim()
    ylim = ax.get_ylim()
    minLimit = min(xlim[0], ylim[0])
    maxLimit = max(xlim[1], ylim[1])
    ax.axis([minLimit, maxLimit] * 2)

Ideally something like this would be built into matplotlib. Maybe it already is and I missed it? If not, it would be a handy addition. Beats having everyone copy/paste the wheel - I must have seen it implemented over a hundred times.

@WeatherGod
Copy link
Member

the set_aspect() method has the "adjustable" parameter that allows values
of "box", "datalim", and "box-forced". I think you want "box" with "equal".

Cheers!
Ben Root

On Thu, Oct 30, 2014 at 4:16 PM, Jesse Johnson notifications@github.com
wrote:

When using pyplot, I can use axis('equal') to make the axes have the same
scale (a circle is a circle). However, this leaves a hole for the common
case of comparing experiment with theory where a square plot is desired
(i.e., the axes should have the same limits).

To achieve this, I typically write a function:

def equalAxisLimits(ax):
'''
Make both axes have the same range. Useful for producing square plots.
'''
xlim = ax.get_xlim()
ylim = ax.get_ylim()
minLimit = min(xlim[0], ylim[0])
maxLimit = max(xlim[1], ylim[1])
ax.axis([minLimit, maxLimit] * 2)

Ideally something like this would be built into matplotlib. Maybe it
already is and I missed it? If not, it would be a handy addition. Beats
having everyone copy/paste the wheel - I must have seen it implemented over
a hundred times.


Reply to this email directly or view it on GitHub
#3742.

@efiring
Copy link
Member

efiring commented Oct 30, 2014

No, he is asking for a way to automatically make the X and Y data limits the same, so that with adjustable 'box' and aspect 'equal', the result would be a square with identical min/max values for X and Y.

@holocronweaver
Copy link
Author

Yes, what @efiring said. 😄

@tacaswell tacaswell added this to the unassigned milestone Oct 30, 2014
@WeatherGod
Copy link
Member

Ah, I should have read the code example. So really, this isn't so much an
aspect issue as much as an autoscaling issue. Perhaps it would make sense
to add some sort of feature analogous to sharex/sharey, but for inter-axes
sharing rather than intra-axes sharing? Would have to be careful with
handling panning, but would be killer for zooming.

On Thu, Oct 30, 2014 at 5:57 PM, Jesse Johnson notifications@github.com
wrote:

Yes, what @efiring https://github.com/efiring said. [image: 😄]


Reply to this email directly or view it on GitHub
#3742 (comment)
.

@tacaswell
Copy link
Member

Closed by #4310

@QuLogic QuLogic modified the milestones: v1.5.0, unassigned Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants