顯示具有 matplotlib 標籤的文章。 顯示所有文章
顯示具有 matplotlib 標籤的文章。 顯示所有文章

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

2017年7月5日 星期三

Python - matplotlib pyplot - How to change figure size of 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
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = (8,5)
plt.plot([1,2,3,4],[1,2,1,3])
plt.show()
Result: