0

i'm trying to make the default font type to "Times New Roman" in matplotlib but its saying "/usr/local/lib/python3.6/dist-packages/matplotlib/font_manager.py:1241: UserWarning: findfont: Font family ['times new roman'] not found. Falling back to DejaVu Sans. (prop.get_family(), self.defaultFamily[fontext]))". but when i'm using the key word "Times new roman" it's not showing me the above error but still i'm pretty sure that the folt that is being generated is not Times New Roman

please help, i need Times new roan font as the default one

 import matplotlib.pyplot as plt
 plt.rcParams["font.family"] = "times new roman"

plt.figure(figsize=(10,8))
plt.plot([1,2,3], [1,2,3])
plt.title('title', fontsize = 30)
plt.xlabel('title', fontsize = 30)
plt.savefig("/content/after.png", dpi = 500, bbox_inches='tight')
plt.show()

before using "Times new roman" after using "Times new roman"

Quamer Nasim
  • 366
  • 1
  • 5
  • 18
  • Can you make this reproducible, e.g. replacing the heatmap by `plt.plot([2,3,1])` and show a picture of how it looks so one can judge on what other font it may be? – ImportanceOfBeingErnest Oct 02 '19 at 12:31
  • @ImportanceOfBeingErnest done bro, can you please check it out – Quamer Nasim Oct 02 '19 at 13:47
  • @ImportanceOfBeingErnest please tell me on how to download the font as the instruction is saying that you don't have it, so please tell me on how to download "Times New Roman" font for matplotlib – Quamer Nasim Oct 02 '19 at 13:59
  • I do have a very similar problem ([shown here](https://discourse.matplotlib.org/t/times-new-roman-font-is-always-bold/20608)). But in your case, are you sure to have Times new roman installed at all? – ImportanceOfBeingErnest Oct 02 '19 at 14:05
  • @ImportanceOfBeingErnest i don't think that "Times New Roman" is pre-installed, and I don't know how to install, do you have any idea on how to install – Quamer Nasim Oct 02 '19 at 15:03
  • No, but installing a font is not a programming problem. You will surely find solutions to it by googling for "Install on ". – ImportanceOfBeingErnest Oct 02 '19 at 15:28
  • It looks like you're using an OS with case sensitive file names. Are you sure it's not just a spelling problem? – Mark Ransom Oct 03 '19 at 14:38
  • Have you tried this: https://stackoverflow.com/a/71692086/5599687? – Gabriele Mar 31 '22 at 12:01

0 Answers0