I have a problem that I thought would be more noticeable. However, after cleaning the Internet for some time, I could not find a solution to my problem. So here it is:
For a plot created using matplotlib.pyplot, I want to include the SI-unit micrometer in my xlabel. However, the microcomputer must be upright. After some messing around I reached the desired xlabel.
The code I have to generate is:
import matplotlib import matplotlib.pyplot as plt matplotlib.rc('text', usetex = True) params = {'text.latex.preamble': [r'\usepackage{siunitx}', r'\usepackage{cmbright}']} plt.rcParams.update(params) fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.set_xlabel('$\si{\micro \meter}$', fontsize = 16) ax.set_ylabel("hi", fontsize = 16) plt.savefig("test.png")
The result is shown below:
The micrometer is exactly what I want. However, the problem is that the font of the x and y ticks is changing. This is due to:
matplotlib.rc('text', usetex = True)
How can I reset font values ββto their original values? Or how can I make sure the fonts do not change when typing tex?
By reference, the initial values ββthat I have in mind are as follows:
In addition to trying to return the fonts back to their original values, I also tried different methods for including a micrometer in my xlabel. The problem that arises here is that it stays italic or bold. The micrometer I'm looking for is the one shown in the first image.
I hope someone helps me solve this problem.
Thanx in advance
source share