pythonmatplotlibplot

How can I make the length of the spacing the same in x and y axis?


matplotlib showing unequal axis

As one can see from the above picture, 1 unit on x-asis of the graph is different from that on y-axis (in terms of length). (So you see rectangle instead of square.)

I would like to ask how can I make it the same? Thanks in advance.


Solution

  • You can force matplotlib to use the same scaling for both axes by adding the following to your plot:

    plt.axis('equal')
    

    More information can be found here: axis_equal_demo.py