简体   繁体   English

如何显示交互式绘图间谍python 3.5.2

[英]How to display interactive plot spyder python 3.5.2

i wanted to to have 3d plot were the z values change every second and the change is displayed in the plot. 我想要3d图是z值每秒更改一次,并且更改显示在图中。 And it works...kinda. 它的工作原理……有点。 Only the very last plot is actually shown. 实际上只显示最后一个图。 Before that the Figure just stays blank. 在此之前,该图只是空白。 I thought it had to do with my script. 我认为这与我的脚本有关。 But then I used a working example from the rawspberry website with exactly the same result. 但随后,我使用了rawspberry网站上的一个有效示例,其结果完全相同。 Blank window, after script is done the last actually gets displayed. 空白窗口,脚本完成后,实际上显示了最后一个窗口。 I can't find any working solution for this problem so far. 到目前为止,我找不到任何可行的解决方案。

Here is the code of the example from the rwaspberry website: 这是rwaspberry网站上的示例代码:

    import matplotlib.pyplot as plt
    from time import sleep
    from random import shuffle

    plt.ion()

    y = [i for i in range(100)]
    x = [i for i in range(len(y))]

    for i in range(50):
        plt.clf()
        plt.bar(x,y)
        plt.draw()
        sleep(0.5)
        shuffle(y) 

Use plt.pause() instead of sleep() 使用plt.pause()代替sleep()

for i in range(50):
    plt.clf()
    plt.bar(x,y)
    plt.draw()
    plt.pause(0.5)
    shuffle(y) 

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

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