gnuplot从给定的数据点绘制错误的图形

发布于 2025-01-21 18:45:29 字数 708 浏览 2 评论 0原文

我有一个包含一些数据点的文件:

# energytime.dat
# X Y
64.934 1993
64.9264 0.0029
64.9022 1897
64.9296 1877
64.8698 1885
64.953 3799

我编写了以下脚本来绘制图形:

#!/usr/bin/gnuplot -persist
set title "Energy vs. Time for all algorithms"
set xlabel "Energy"
set ylabel "Time"
set style line 1 \
    linecolor rgb '#0060ad' \
    linetype 1 linewidth 2 \
    pointtype 7 pointsize 1.5
plot "energytime.dat" with linespoints linestyle 1
pause -1 "Hit Enter to continue"

这给出以下图:
显然,这个情节是错误的。我应该对脚本进行哪些修改以获取正确的图表?

I have a file containing some datapoints:

# energytime.dat
# X Y
64.934 1993
64.9264 0.0029
64.9022 1897
64.9296 1877
64.8698 1885
64.953 3799

I wrote the following script to plot a graph:

#!/usr/bin/gnuplot -persist
set title "Energy vs. Time for all algorithms"
set xlabel "Energy"
set ylabel "Time"
set style line 1 \
    linecolor rgb '#0060ad' \
    linetype 1 linewidth 2 \
    pointtype 7 pointsize 1.5
plot "energytime.dat" with linespoints linestyle 1
pause -1 "Hit Enter to continue"

This gives the following graph:
wrong graph

It is obvious that this plot is wrong. What modifications should I make to my script to get the correct graph?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微凉徒眸意 2025-01-28 18:45:30

正如@theozh所写,GNUPLOT只是按照数据文件中存储的顺序绘制数据。但是,您可以使用平滑唯一“更正”图形

plot "energytime.dat" smooth unique with linespoints linestyle 1

(假设您永远不会有两个相同的x值)。

注意

与之前使用平滑唯一很重要。

As @theozh wrote, gnuplot simply plots the data in the order they stored in the datafile. However, you can "correct" your graph with smooth unique

plot "energytime.dat" smooth unique with linespoints linestyle 1

(assuming, that you will never have two identical x values).

good result

NOTE

It is important, to use smooth unique before with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文