Gnuplot:第0行:用于绘制预期的函数 [英] Gnuplot: line 0: function to plot expected
问题描述
我有一个python脚本,可以使用gnuplot生成图形.但是我有一个错误:
I've a python script who generate a graphic with gnuplot. But I've an error:
gnuplot>情节 ^ 第0行:用于绘制预期的函数
gnuplot> plot ^ line 0: function to plot expected
g=Gnuplot.Gnuplot(persist=1)
g.title('Read&Write Performance')
g.xlabel('minutes')
g.ylabel('MB/s')
g('set term png')
g('set out')
g('set yrange [0:70]')
d1=Gnuplot.Data(self.time,self.list1,title="perfr", with_="line")
d2=Gnuplot.Data(self.time,self.list2,title="perfw", with_="line")
time.sleep(2)
g.hardcopy('bench.png',terminal = 'png')
g.reset()
self.list1 = [12、15、17] self.list2 = [43,48,49]
self.list1= [12, 15, 17] self.list2 = [43, 48, 49]
我不明白为什么会出现此错误.
I don't understand why I've this error.
谢谢:)
推荐答案
非常简短之后,查看源代码,看来g.plot()不会将绘图发送到窗口(例如x11),但可以将gnuplot当前配置为发送绘图的任何地方.因此,(我认为)最简单的解决方案是-
After a very brief look at the source, it seems that g.plot() does not send the plot to a window (e.g. x11), but to wherever gnuplot is currently configured to send the plot. So, (I think) the easiest solution is --
g('set terminal png')
g('set output "bench.png"')
g.plot(d1) #d1 should not be in "bench.png"
#This might work to plot both datasets together ... g.plot(d1,d2)
只要发出plot
命令,只要gnuplot-py的内部结构不重置gnuplot脚本,此方法就应该起作用.我非常怀疑是这种情况,因为__call__
方法似乎是API中如此重要的部分.
This should work as long as the internals of gnuplot-py don't reset the gnuplot script whenever a plot
command is issued. I highly doubt this is the case since the __call__
method seems to be such an important part of the API.
这篇关于Gnuplot:第0行:用于绘制预期的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!