免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5174 | 回复: 3
打印 上一主题 下一主题

windows平台使用python 调用gnuplot画图后窗口不能保持 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-12-11 22:12 |只看该作者 |倒序浏览
本帖最后由 aidixiao 于 2012-12-11 22:13 编辑

使用下面的代码:
#!/usr/bin/env python
import Gnuplot, Gnuplot.funcutils
from numpy import *
gp = Gnuplot.Gnuplot()
gp('set data style lines')

data1 = [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16]]
plot1 = Gnuplot.PlotItems.Data(data1, with_="lines", title="Quadratic")
data2 = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]
gp.plot(plot1,data2)

能正常画图,就是画完后窗口一闪就没了,在gp = Gnuplot.Gnuplot()括号内加persist=1参数的话,又显示错误,
"gnuplot persist is not support in windows",想向各位大侠请教一下,通过什么方法使画完图的窗口保持住.
谢谢了.

论坛徽章:
0
2 [报告]
发表于 2012-12-24 19:24 |只看该作者
我也遇到同样的问题。
def plot(energies):
    from Gnuplot import Gnuplot, Data
    p = Gnuplot()
    d = Data(range(len(energies)),energies)
    p.plot(d)
    return
   
data = [1,2,3,4,5]
plot(data)

论坛徽章:
0
3 [报告]
发表于 2012-12-24 21:22 |只看该作者
我找到一个答案了
On some platforms, some backends may result in a plot that is shown in just a fraction of a second on the screen before the plot window disappears (using the Gnuplot backend on Windows machines or using the Matplotlib backend constitute two examples). To make the window stay on the screen, add
raw_input('Press the Return key to quit: ')
at the end of the program. The plot window is killed when the program terminates, and this satement postpones the termination until the user hits the Return key.

论坛徽章:
0
4 [报告]
发表于 2012-12-26 11:15 |只看该作者
感谢weitongwei分享答案,问题解决了.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP