1. backend
有时保存的图片不只是png, 可能还需要pdf, 因此设置可以设置好backedn
参考资料: https://matplotlib.org/stable/api/matplotlib_configuration_api.html
- interactive backends: GTK3Agg, GTK3Cairo, GTK4Agg, GTK4Cairo, MacOSX, nbAgg, QtAgg, QtCairo, TkAgg, TkCairo, WebAgg, WX, WXAgg, WXCairo, Qt5Agg, Qt5Cairo
- non-interactive backends: agg, cairo, pdf, pgf, ps, svg, template
2. rcParams
可设置的属性列表: https://matplotlib.org/stable/api/matplotlib_configuration_api.html?highlight=rcparams#matplotlib.rcParams
2.1 DPI (涉及清晰度)
1
| plt.rcParams['figure.dpi'] = 200
|
2.2 字体
1 2 3 4
| plt.rcParams.update({ "font.size":20, 'font.sans-serif': "simsun" })
|
2.2.1 ubuntu支持中文
1 2 3 4
| import matplotlib print(matplotlib.matplotlib_fname())
|
1 2 3 4 5 6 7
| cd ~/APP/anaconda/anaconda3/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf
rm ~/.cache/matplotlib
|