Python Changing the default font in matplotlib to "Times New Roman".

  • Thread starter Thread starter amjad-sh
  • Start date Start date
  • Tags Tags
    Font Matplotlib
AI Thread Summary
To submit an article to an APS journal with figures labeled in "Times New Roman" using Matplotlib, users need to set the default font correctly. Initial attempts to check font availability revealed that "Times New Roman" was not found, suggesting it may need to be added to Matplotlib. Users can refer to external resources for guidance on changing fonts in Matplotlib. A challenge remains with mathematical text appearing bold, despite efforts to adjust the font weight using `matplotlib.rcParams['axes.labelweight']`. This issue indicates that a different font may be necessary for math symbols to achieve the desired appearance. It is advised to consult the journal's guidelines regarding figure submissions, as they may have specific requirements or recommendations for fonts. Additionally, focusing on more critical project elements is encouraged to avoid missing deadlines over minor issues.
amjad-sh
Messages
240
Reaction score
13
I want to submit an article to an aps journal, so the labels of the figures have the "Times New Roman" font.
I had used the package matplotlib to get the figures and I want to make "Times New Roman" the default font. So, what code I need to write for this to be achieved?
Note that I used the package subplots to get the figures, by implementing this code:
from matplotlib.pyplot import subplots, show

I also tried the code below to check if the font is available:

import matplotlib.font_manager
flist = matplotlib.font_manager.get_fontconfig_fonts()
names = [matplotlib.font_manager.FontProperties(fname=fname).get_name() for fname in flist]
print (names)
if "Times New Roman" in names:
print ("Yes")
else:
print ("font not available")

and the output was "font not available". Does this mean I need to add it to matplotlib? and if yes, how?
 
Technology news on Phys.org
amjad-sh said:
and the output was "font not available". Does this mean I need to add it to matplotlib? and if yes, how?
Might it be called just "Times" in the package?
 
  • Like
Likes amjad-sh and jedishrfu
anorlunda said:
Might it be called just "Times" in the package?
I think the last code I wrote is meaningless, because I tried @jedishrfu's link and could change the default font into Times New Roman. But a problem still remaing. The part of the label which is written in mathmode always appears bold:
r"\mathcal{L}^s$"
I want the boldness of the text written in mathmode and the rest of the text be the same ( I want the font to be light). What is needed to be done for this to be achieved?
 
amjad-sh said:
I want the boldness of the text written in mathmode and the rest of the text be the same

Matplotlib does have a fontweight (or just weight) property that can be applied to most text.
 
websterling said:
Matplotlib does have a fontweight (or just weight) property that can be applied to most text.
I used this code to make the weight of the labels appears light:
matplotlib.rcParams['axes.labelweight']=100,
but the the mathematical symbols written in the mathmode still look bold.
 
Isn't this bold issue a nit? It may be that a different font is required for the math symbols to be properly displayed.

You could generate a plot and send it to the publishing journal editor to see if it is acceptable or if they have any guidelines on how best to make a plot. Their rules might only apply to the article and not the plot images. They may also have some recommended font packages to use as well.

Do you have other more pressing things to work on to complete your project? or is this the last thing? I'm asking because sometimes we focus on a minor issue to the detriment of other things we need to solve. I've done this too and missed deadlines which teach you to stay focused on the end goal.
 
  • Like
Likes amjad-sh

Similar threads

Back
Top