matplotlib(1)-- figure創建


 1 import matplotlib.pyplot as plt
 2 import numpy as np
 3 
 4 x = np.linspace(-3, 3, 50)
 5 y1 = 2 * x + 1
 6 y2 = x ** 2
 7 
 8 #figure 1
 9 plt.figure()
10 plt.plot(x, y1)
11 
12 #figure 2
13 plt.figure()
14 plt.plot(x, y2)
15 
16 #figure 4,指定figure的編號並指定figure的大小
17 plt.figure(num = 4, figsize = (8, 5))
18 plt.plot(x, y1, color = "red", linewidth = 5.0, linestyle = '--')    #指定線的顏色, 寬度和類型
19 plt.plot(x, y2)
20 
21 plt.show()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM