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