简体   繁体   English

matplotlib.pyplot 没有显示一些图

[英]matplotlib.pyplot doesn't show SOME of the plots

Edit: mistake of my own was found...编辑:发现我自己的错误...

"I'm trying to plot multiple curves on a graph with python, and from previous experiences matplotlib.pyplot seemed to be the way to go, but I'm defeated... "I'm trying to plot multiple curves on a graph with python, and from previous experiences matplotlib.pyplot seemed to be the way to go, but I'm defeated...

At the end of my code, I plot the main curve with在我的代码末尾,我 plot 的主曲线与

plt.plot(c0, c1)    # with c0 and c1 being two lists
plt.show()

and this works fine, but when I add another curve like:这很好用,但是当我添加另一条曲线时:

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

then only the first one shows up.然后只有第一个出现。 I also tried removing the main curve, but then I don't even have the plot windows...我也尝试删除主曲线,但后来我什至没有 plot windows ...

Anyone knows this issue?"有谁知道这个问题?”

Matplotlib lets you add different plots in a single figure by default.默认情况下,Matplotlib 允许您在单个图中添加不同的图。

Some of the things you can check:您可以检查的一些事项:

1) if c1 and g lists are the same( and they are overlapping in the plot?) 1)如果 c1 和 g 列表相同(并且它们在 plot 中重叠?)

2) if g is empty(but you not even getting a plotting window after removing plot with c1 is definitely strange) 2)如果 g 是空的(但在用 c1 删除 plot 后你甚至没有得到一个绘图 window 肯定很奇怪)

# 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')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM