gpt4 book ai didi

python - 无法使用 gnuplot.py 指定 x 范围

转载 作者:行者123 更新时间:2023-12-01 05:03:28 25 4
gpt4 key购买 nike

我目前正在尝试在 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')

最佳答案

你只缺少一个

g('set xdata time')

因此,gnuplot 尝试解析字符串和数字,最终得到 set xrange [15:15],这是一个空范围。您将通过

观察到相同的错误消息
set xrange ["15:43:59":"15:48:56"]
plot x

关于python - 无法使用 gnuplot.py 指定 x 范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25530879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com