我目前正在尝试使用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')
答案 0 :(得分:2)
你只是错过了
g('set xdata time')
因此,gnuplot尝试解析字符串数字,最后是set xrange [15:15]
,这是一个空范围。您将使用
set xrange ["15:43:59":"15:48:56"]
plot x