- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change fonts in matplotlib (python)?
Using plt.text() method, we can increase the font size.
Steps
Using plt.plot() method, we can create a line with two lists that are passed in its argument.
Add text to the axes. Add the text *s* to the axes at location *x*, *y* in data coordinates, using plt.text() method. Font size can be customized by changing the font-size value.
To show the figure, use plt.show() method.
Example
import matplotlib.pyplot as plt plt.plot([1, 2, 4], [1, 2, 4]) plt.text(2, 3, "y=x", color='red', fontsize=20) # Increase fontsize by increasing value. plt.show()
Output
Advertisements