Python | Equal Axis Scale Ratio in Plotting

Here, we are going to learn about the equal axis scale ratio in plotting and its Python implementation.
Submitted by Anuj Singh, on July 31, 2020

In some cases, the axis ratio is important such as, the axis must be on the same scale. Our example illustrates that a circle can be an ellipse if the axis scales are not the same. We have an inbuilt defined function within matplotlib.pyplot library for this operation and the following example shows the illustration.

Equal Axis Scale Ratio in Plotting (1)

Python code for equal axis scale ratio in plotting

import numpy as np
import matplotlib.pyplot as plt

an = np.linspace(0, 2*np.pi, 100)

plt.subplot(121)
plt.plot(3*np.cos(an), 3*np.sin(an))
plt.title('Not equal axis Ratio, looks like ellipse', fontsize=10)

plt.subplot(122)
plt.plot(3*np.cos(an), 3*np.sin(an))
plt.axis('equal')
plt.title('Equal axis Ratio, looks like circle', fontsize=10)

Output:

Output is as figure





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.