If we use "equal" as an aspect ratio in the function, we get a plot with the same scaling from data points to plot units for X-axis and Y-axis. It sets both X-axis and Y-axis to have the same range. Then ax. set_aspect('equal') sets both axes to be equal.
Import matplotlib. To set x-axis scale to log, use xscale() function and pass log to it. To plot the graph, use plot() function. To set the limits of the x-axis, use xlim() function and pass max and min value to it. To set the limits of the y-axis, use ylim() function and pass top and bottom value to it.
Adjust axis limits: To set the limits of x and y axes, we use the commands plt. xlim() and plt. ylim().
You need to dig a bit deeper into the api to do this:
from matplotlib import pyplot as plt
plt.plot(range(5))
plt.xlim(-3, 3)
plt.ylim(-3, 3)
plt.gca().set_aspect('equal', adjustable='box')
plt.draw()
doc for set_aspect
plt.axis('scaled')
works well for me.
See the documentation on plt.axis()
. This:
plt.axis('equal')
doesn't work because it changes the limits of the axis to make circles appear circular. What you want is:
plt.axis('square')
This creates a square plot with equal axes.
Try something like:
import pylab as p
p.plot(x,y)
p.axis('equal')
p.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With