SciencePlots icon indicating copy to clipboard operation
SciencePlots copied to clipboard

Why not Times New Roman font?

Open ouening opened this issue 3 years ago • 3 comments

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!

ouening avatar Sep 28 '20 07:09 ouening

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.

garrettj403 avatar Sep 28 '20 21:09 garrettj403

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:

a

If not, the result is: image

ouening avatar Oct 26 '20 01:10 ouening

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:

fig2-error

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)'.

garrettj403 avatar Nov 30 '20 16:11 garrettj403

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.

JBorrow avatar May 23 '23 15:05 JBorrow

Since STIX fonts have been included in science and ieee styles, I'm closing this.

Thanks JBorrow!

echedey-ls avatar May 30 '23 08:05 echedey-ls