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()

 

posted @ 2019-07-25 21:18  小伙郭  阅读(787)  评论(0编辑  收藏  举报