【发布时间】:2012-05-04 18:14:12
【问题描述】:
我一直在互联网上寻找答案。
在 gnuplot 中如何绘制颜色线似乎有很多版本。 我有一个包含 4 列的数据文件。我想用不同的颜色绘制每一列。 这是我根据 gnuplot 帮助文件使用的代码的 sn-p,但是当我使用这些时出现语法错误。
set style line 1 lt 1 lc 1 lw 3 # red
set style line 2 lt 1 lc 2 lw 3 #green
set style line 3 lt 1 lc 3 lw 3 #blue
set style line 4 lt 1 lc 4 lw 3 #magenta
我已将终端设置为 postscript。
我已经尝试过这种线型样式的所有组合,包括线型和 lc rgb 'red',例如,它们都不起作用!
谁能告诉我怎么了?
让我澄清一下,这是 python 脚本中的 gnuplot 脚本。代码如下:
plot = open('plot.pg','w')
plot_script = """#!/usr/bin/gnuplot
reset
set terminal postscript
#cd publienhanced color
set output "roamingresult.ps"
set xlabel "time (seconds)"
set xrange [0:900]
set xtics (0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900)
set ylabel "AP1 AP2 AP3 AP4"
set yrange [0:5]
set nokey
set grid
set noclip one
set ytics 1
#set style data boxes"""
set style line 1 lt 1 lc 1 lw 3
set style line 2 lt 1 lc 2 lw 3
set style line 3 lt 1 lc 3 lw 3
set style line 4 lt 1 lc 4 lw 3
【问题讨论】:
-
对于初学者,您使用的 sn-p 不是 Python。我对 Gnuplot 了解不多,但看起来您使用的脚本只是一个标准的 Gnuplot 脚本。您可能会尝试将其作为 Python 脚本调用吗?
-
另外,向我们提供错误的 sn-p 会有所帮助。
-
语法错误是这样的:set style line 1 lt 1 lc 1 lw 3 ^ SyntaxError: invalid syntax
-
啊,很好。为了将来参考,您几乎应该总是发布您的错误/堆栈跟踪,以及相关的代码示例。没有它可能很难查明您的问题。请参阅我的答案以解决您的问题。
-
另外,我刚刚编辑了您问题的语法。我将您的代码示例指定为 Python。语法突出显示应该向您显示您的错误。