1.问题:
和题目一样,pycharm中,matplotlib.pyplot.show()显示的图表,输出到sciview,怎么弹出来?
2.代码:
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
style.use('fivethirtyeight')
fig = plt.figure(figsize=(9, 6))
ax1 = fig.add_subplot(1, 1, 1)
def animate(i):
graph_data = open('result.txt', 'r').read()
lines = graph_data.split('\n')
xs = []
ys = []
for line in lines:
if len(line) > 1:
x, y = line.split(' ')
xs.append(int(x))
ys.append(int(y))
ax1.clear()
ax1.plot(xs, ys)
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
result.txt里面是数据,两列,中间空格,格式:
0 9057
1 9239
2 9262
3 9339
······
3.运行结果:
本人是笔记本,pycharm版本2017.3.1,python版本3.6.4:
在其他电脑上试了下,代码一样,台式机,pycharm版本2017.2.4,python版本3.6.2,结果是下面:
这个效果正是我想要的,可是我的电脑运行不出来,什么问题?
4.自己思考:
我的是直接把结果输出到了SciView窗口中,在View-Tool Windows中,能看到这个选项,但是我测试的台式机的pycharm上面,View-Tool Windows没有这个选项,那么,就应该是pycharm版本的问题。
在cmd中执行,是正常的,但是在pycharm中不行,没有找到怎么办,百度SciView,结果很少。
求助。
嗯,自己找到答案了。
SciView in PyCharm 2017.3 reduces functionality of Matplotlib
具体办法:Settings | Tools | Python Scientific | Show Plots in Toolwindow,去掉