Matplotlib: Times New Roman Appears Bold
Solution 1:
I know the question is very old, but it still is a problem, at least for me on my mac. I found a very easy solution to this problem, posted by azag0 on github
del matplotlib.font_manager.weight_dict['roman']
matplotlib.font_manager._rebuild()
Solution 2:
Digging into more details I realized that the bug is real and that mpl
is actually selecting a Times New Roman Bold font.
The font selection algorithm in font_manger.py
assigns weights on every font it finds based on the family, variant, weight, etc. (around line 1290). The "name" coming from Times New Roman Bold.ttf
is just 'Times New Roman' which might make sense, but the weight is 500, the same value as the regular font:
<Font 'Times New Roman' (Times New Roman Bold.ttf) normal normal 500 normal>with score 0.1<Font 'Times New Roman' (Times New Roman.ttf) normal normal 500 normal>with score 0.1
On my Mac and Linux setup the bold one is encountered first and is selected by the code
if score < best_score:
best_score = scorebest_font= font
I dirty patch is to replace <
by <=
...
Solution 3:
I recently experienced this problem when the matlibplot updated from 2.2.3 to 3.1.0. I tried a lot of answers here and from other websites, but the font "times new roman" still appeared bold. But I remembered last time when it was still 2.2.3, the font appeared normal. So I just replaced the font_manager.py in the 3.1.0 by the font_manager.py in the 2.2.3:
copy the font_manager.py in ..\anaconda\pkgs\matplotlib-2.2.3-py37hd159220_0\Lib\site-packages\matplotlib
and paste it here: ..\anaconda\pkgs\matplotlib-3.1.0-py37hc8f65d3_0\Lib\site-packages\matplotlib
I hope it helps.
Solution 4:
As mentioned the font selection algorithm picks the first font in the Time New Roman family, which has four different files (bold, bold italic, italic and regular). So the steps would be:
- Go to
C:\Windows\Fonts\Times New Roman
- Right-click → Sort by → Descending (the order will change so the Times New Roman Regular will end up as the first, and that will be the font the algorithm will choose).
Solution 5:
Removing ~/.cache/matplotlib/
solved the problem for me.
Post a Comment for "Matplotlib: Times New Roman Appears Bold"