X Tutup
Skip to content

Square plots #3742

@holocronweaver

Description

@holocronweaver

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup