2017年7月6日 星期四

Python - How to change the font size on a matplotlib pyplot - 如何改變matplotlib pyplot 顯示的字體大小

Python version:Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
matplotlib version:2.0.0
System version:Windows 10
# before change
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = (8,5)
plt.plot([1,2,3,4],[1,2,1,3])
plt.title('Series trend')
plt.show()
# after change
from matplotlib import pyplot as plt
fontsize_set = 18
plt.rcParams["figure.figsize"] = (8,5)
plt.rc('xtick' , labelsize=fontsize_set) 
plt.rc('ytick' , labelsize=fontsize_set)  
plt.rc('legend', fontsize=fontsize_set) 
plt.rc('font'  , size=fontsize_set)
plt.plot([1,2,3,4],[1,2,1,3])
plt.title('Series trend')
plt.show()
Result:
before change
after change

沒有留言:

張貼留言