
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Obtain Same Font in Matplotlib as in LaTeX Output
To make bold font weight LaTeX axes label in matplotlib, we can take the following steps−
- Create data points for x.
- Create data points for y, i.e., y=sin(x).
- Plot the curve x and y with LaTex representation.
- To activate the label, use legend() method.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt, font_manager as fm fprop = fm.FontProperties(fname='/usr/share/fonts/truetype/malayalam/Karumbi.ttf') plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(1, 10, 1000) y = np.sin(x) plt.plot(x, y, label=r'$\sin (x)$', c="red", lw=2) plt.title(label=r'$\sin (x)$', fontproperties=fprop) plt.show()
Output
Advertisements