Python数据可视化2-多figure显示

这里显示两个figure,即两个窗口,第一个figure显示一个函数,第二个figure显示两个函数
代码:

import matplotlib.pyplot as plt
import numpy as np
# 定义数据
x = np.linspace(-3, 3, 50)
y1 = 2*x + 1
y2 = x**2
# 第一个figure
plt.figure()
plt.plot(x, y1)
# 第二个figure
plt.figure(num=3, figsize=(8, 5),)  # 尺寸(8,5)
# 第二个figure包含两个函数的显示
plt.plot(x, y2)
plt.plot(x, y1, color='red', linewidth=1.0, linestyle='--')  # 虚线
# 显示图像
plt.show()

这里写图片描述
这里写图片描述

猜你喜欢

转载自blog.csdn.net/ohcezzz/article/details/80677465
今日推荐