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
  1. # before change
  2. from matplotlib import pyplot as plt
  3. plt.rcParams["figure.figsize"] = (8,5)
  4. plt.plot([1,2,3,4],[1,2,1,3])
  5. plt.title('Series trend')
  6. plt.show()
  7. # after change
  8. from matplotlib import pyplot as plt
  9. fontsize_set = 18
  10. plt.rcParams["figure.figsize"] = (8,5)
  11. plt.rc('xtick' , labelsize=fontsize_set)
  12. plt.rc('ytick' , labelsize=fontsize_set)
  13. plt.rc('legend', fontsize=fontsize_set)
  14. plt.rc('font' , size=fontsize_set)
  15. plt.plot([1,2,3,4],[1,2,1,3])
  16. plt.title('Series trend')
  17. plt.show()
Result:
before change
after change

沒有留言:

張貼留言