Python | Fraction in Matplotlib

In this article, we are going to learn how to plot a fraction in figure using matplotlib?
Submitted by Anuj Singh, on August 20, 2020

Illustrations:

Python | Fraction in Matplotlib (1)

Python | Fraction in Matplotlib (2)

Python | Fraction in Matplotlib (3)

Python code for fraction in matplotlib

import matplotlib.pyplot as plt

plt.figure()
plt.text(0.5, 0.5, r"$\frac{4}{32}$", fontsize=60)
plt.axis(False)
plt.show()

plt.figure()
plt.text(0.5, 0.5, r"$\frac{1}{3}$", fontsize=60)
plt.axis(False)
plt.show()

plt.figure()
plt.text(0.5, 0.5, r"$\frac{a}{b}$", fontsize=60)
plt.axis(False)
plt.show()

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.