SciencePlots
SciencePlots copied to clipboard
Why not Times New Roman font?
Hi, I see many figures use Times New Roman font as default. Why don't you use it? If I want, how could I change the code? Thank you!
I'm not too sure what you mean... but the font is set on line 41 of science.mplstyle
:
# Use serif fonts
font.serif : Times New Roman
font.family : serif
mathtext.fontset : dejavuserif
You can overwrite this however you like.
I have figured out why the font is not Times New Roman. In https://matplotlib.org/3.1.1/tutorials/text/usetex.html, the example is
font.family : serif
font.serif : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
font.sans-serif : Helvetica, Avant Garde, Computer Modern Sans serif
font.cursive : Zapf Chancery
font.monospace : Courier, Computer Modern Typewriter
text.usetex : true
So I update the code like:
plt.style.use(['science','ieee'])
plt.rcParams.update({
"legend.fancybox": False,
"legend.frameon": False,
"text.usetex": True,
"font.family": "serif",
"font.serif": ["Times"],
"font.size":11})
Result is:
If not, the result is:
Hi @ouening
Sorry for the long delay. I tried switching to the Times
font, but then the special math characters fail to render in the PDFs. For example, ax.set_ylabel='Current ($\mu$A)'
results in:
This previously worked fine, so for now I'll leave the SciencePlots font as the default serif font until I figure out what is wrong.
Note: For the ieee
style, I changed the default font to Times
(see commit b0de4cafe5bd5e2d2764b8eb7febd4141b095923). To get this to work however, I had to change the y-axis label to: ax.set_ylabel='Current (\textmu A)'
.
As a note you may wish to use the STIX fonts that look very similar to Times but are fully open. The problem with math rendering is that the usual Times font does not include all the required glyphs.
Since STIX fonts have been included in science
and ieee
styles, I'm closing this.
Thanks JBorrow!