I am having trouble setting the bold face for 'Helvetica Neue' font while using matplotlib plot. It works file with 'Arial' but somehow bold face for 'Helvetica Neue' doesn't work. Any suggestion?
Here the python code I am using:
mpl.rcParams['xtick.labelsize'] = 14
mpl.rcParams['ytick.labelsize'] = 14
mpl.rcParams['font.family'] = 'sans-serif'
#mpl.rcParams['font.sans-serif'] = ['Arial Narrow']
#mpl.rcParams['font.sans-serif'] = ['Arial']
mpl.rcParams['font.sans-serif'] = ['Helvetica Neue']
mpl.rcParams["font.weight"] = "bold"
mpl.rcParams["axes.labelweight"] = "bold"
mpl.rcParams["axes.labelsize"] = 16
params = {'mathtext.default': 'regular'}
plt.rcParams.update(params)
.
.
.
.
axes.set_xlabel("hello world")
axes.set_ylabel('hello world 1x10$^{555}$ (unit)')
Here are the attached images:
Managed to get it working finally. Here are the steps I took.
Convert the desired .ttc font files to .ttf using the online font converter.
Then paste these .ttf converted files into >>
<python install patl>/python3.9/site-packages/matplotlib/mpl-data/fonts/ttf
Remove the matplotlib cache (important step to see the changes) using
rm -rf ~/.matplotlib/fontlist.cache
and
rm -rf ~/.matplotlib/fontlist.json
Re-run the same code as in the question. It worked all well!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With