无法使用gnuplot.py指定x范围
我现在正在尝试在一个Python脚本中使用gnuplot来生成图表,但遇到了这个错误:
line 0: Can't plot with an empty x range!
我不知道为什么我的xrange没有被识别,因为我已经在我的代码中包含了它,下面是我在Python脚本中写的其他gnuplot代码。
### GNUPLOT CODE ####
g = Gnuplot.Gnuplot()
g('set terminal png')
# Graph layout settings
g('set term png size 1200, 800')
g('set lmargin 8')
g('set rmargin 4')
g('set tmargin 3')
g('set bmargin 3')
# Set the name of the output file
g('set output "' + outputFile + '"')
# Format the time
g('set timefmt "%H:%M:%S"')
g('set format x "%H:%M:%S"')
# Set title and labels of the graph. Specify where the x axis starts and ends.
g('set title "' + title + '"')
g('set xlabel "time"')
g('set ylabel "percent"')
g('set xrange ["15:43:59":"15:48:56"]')
# Use the .txt file specified by the user to create the graph
g('plot "' + inputFile + '" using 1:3 title "user" with lines')
1 个回答
2
你只缺少一个
g('set xdata time')
所以,gnuplot尝试把字符串解析成数字,结果变成了 set xrange [15:15]
,这就变成了一个空的范围。你会在
set xrange ["15:43:59":"15:48:56"]
plot x
中看到同样的错误信息。