如何解决matploblib中的图变得嘈杂
所以我的代码是:
import numpy as np
import matplotlib.pyplot as plt
x = [1,2,3,4,5]
y = [2,6,8,10]
x1 = [1,5]
y1 = [1,9,14,25]
t = np.arange(0.0,2.0,0.01)
s1 = np.sin(2*np.pi*t)
s2 = np.sin(4*np.pi*t)
plt.figure(1)
plt.subplots(211)
plt.plot(x,y)
plt.subplots(212)
plt.plot(x1,y1)
plt.figure(2)
plt.subplot(211)
plt.plot(t,s1)
plt.subplot(212)
plt.plot(t,2*s1)
plt.show()
当我刚运行图2时,一切都很好,但是当我运行所有代码时,图变得嘈杂 也将取代图2来运行一个空的图num1 如你在pic1中看到的结果 pic
解决方法
您的代码中有一个小的错字。
在属于figure(1)
的图中,将您的subplots()
更改为subplot()
(删除结尾的s)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。