March 2014
Beginner to intermediate
222 pages
4h 7m
English
By default, matplotlib will use a different scale for both the axes of a figure. In this recipe, we are going to see how to use the same scale for the two axes of a figure.
To accomplish this, we will need to play with the pyplot API and the Axes object, as shown in the following code:
import numpy as np
import matplotlib.pyplot as plt
T = np.linspace(0, 2 * np.pi, 1024)
plt.plot(2. * np.cos(T), np.sin(T), c = 'k', lw = 3.)
plt.axes().set_aspect('equal')
plt.show()The preceding script draws an ellipse with its real aspect ratio, as follows:

In this example, we display an ellipse where the ...
Read now
Unlock full access