大家好,斯塔克弗洛夫大街上的可爱的人们
我试图用gnuplot绘制数据。我先从一张表格开始,然后拿出我想要的数据。我将此数据写入.dat文件。到目前为止,我只是试图通过命令行来绘制它,但是在它工作之后,我将添加必要的代码来从python脚本中绘制它。
创建.dat文件的代码-
#!/usr/bin/python
file = open("test_m.rdb")
table = open('table.dat', 'w+')
trash = file.readline()
trash = file.readline()
data = file.readline()
i = data.split()
flux = i[2]
observed = i[4]
table.write(flux + " " + observed,)
while 1:
line = file.readline()
i = line.split()
try:
flux = i[2]
observed = i[4]
except IndexError:
break
table.write("\n" + flux + " " + observed)
table.close()
我试图在cygwin中使用的命令和错误-
gnuplot plot table.dat
0.058 2
^
"table.dat", line 1: invalid command
提前谢谢你。我很感激你能给我任何建议。
你可能想要:
使用您的命令,gnuplot正在寻找在名为“plot”的文件中运行的命令,然后在名为“table.dat”的文件中运行table.dat'没有要运行的命令,它有要绘制的数据。使用'-e'与将单引号中的内容放入临时文件(称为temp.gp)中,然后执行
gnuplot temp.gp
相同的操作。这个--persist
使它保持在你的屏幕上(这是你想要的,因为我怀疑你把它保存到一个文件中)。要了解如何将其保存到文件中,请在gnuplot do中:help set term
和help set output
和set term
。编辑
我不太了解cygwin,所以我不知道默认的终端是什么(或者什么终端将被启用)。
有几件事要尝试:
将命令放入文件中
现在运行它:
然后使用任何查看postscripts的工具打开postscript——我经常使用
gv
,但我不知道cygwin上有什么。相关问题 更多 >
编程相关推荐