matplotlib.pyplot不显示某些图

时间:2020-05-12 17:39:51

标签: python python-3.x matplotlib

编辑:发现了我自己的错误...

““我正在尝试使用python在图形上绘制多条曲线,从以前的经验来看,matplotlib.pyplot似乎是要走的路,但是我被击败了...

在代码末尾,我用

绘制主曲线
plt.plot(c0, c1)    # with c0 and c1 being two lists
plt.show()

这很好用,但是当我添加另一条曲线时:

plt.plot(c0, c1)    # with c0 and c1 being two lists
plt.plot=(c0, g)     # with g being another list **// here the = is my mistake**
plt.show()

然后只有第一个出现。我还尝试了删除主曲线,但后来我什至没有绘图窗口...

有人知道这个问题吗?”

1 个答案:

答案 0 :(得分:0)

Matplotlib可让您默认在单个图形中添加不同的图。

您可以检查的一些内容:

1)如果c1和g列表相同(并且在图中它们重叠吗?)

2)如果g为空(但是用c1删除绘图后您甚至都没有得到绘图窗口肯定很奇怪)

# plot first graph with red and next with green
plt.gca().set_color_cycle(['red', 'green'])

plt.plot(c0, c1)
plt.plot(c0, g)

# maybe add legends as well to see if both are plotted?
plt.legend(['y = c1', 'y = g'], loc='upper right')
相关问题