简体   繁体   English

使用 gnuplot 绘制 CSV 数据

[英]Plotting CSV data with gnuplot

I would like to plot a csv file with gnuplot.我想用gnuplot plot csv 文件。 Instead of a line, I want to use points that are evenly distributed along the path of the curve.我想使用沿曲线路径均匀分布的点而不是一条线。 However, the data in the csv file is not evenly distributed, eg like this但是 csv 文件中的数据分布不均,例如像这样

x,p
0,2
1,4
1.1,4.2
1.2,4.4
2.8,7.6
2.85,7.7
4,10

It should be possible to achieve this, but how?应该可以实现这一点,但是如何实现呢?

Here is an example graph where I plot every nth point.这是一个示例图,其中我每隔 n 个点 plot。 Because my numerical solution is so good:-) you only see one line, so I would like to have markers on the one curve.因为我的数值解非常好:-) 你只看到一条线,所以我想在一条曲线上有标记。 But the points should be distributed equidistantly (the current distribution is only due to the nature of the analytical solution).但是这些点应该是等距分布的(目前的分布只是由于解析解的性质)。

在此处输入图像描述

In the development version of gnuplot (5.5) this can be done exactly as asked.在 gnuplot (5.5) 的开发版本中,这可以完全按照要求完成。 smooth path does what you would expect, and pn 7 tells it to place exactly 7 evenly spaced points. smooth path符合您的预期,并且pn 7告诉它准确放置 7 个均匀间隔的点。

$DATA << EOD
0,2
1,4
1.1,4.2
1.2,4.4
2.8,7.6
2.85,7.7
4,10
EOD

set log y
set key top left
set datafile separator comma

plot $DATA smooth path with lp pn 7 title "smooth path pn 7", \
     $DATA with points pt 6 ps 2 title "original points" 

在此处输入图像描述

The current version 5.4 does not offer smooth path , but if your data points are sufficiently close to lying on a smooth curve one of the other smoothing options, eg smooth mcs , may be acceptable.当前版本 5.4 不提供smooth path ,但如果您的数据点足够接近位于平滑曲线上,则其他平滑选项之一(例如smooth mcs )可能是可以接受的。

For the record, I think this is not a good thing to do.作为记录,我认为这不是一件好事。 It is dishonest to hide the actual data points while showing artificially even points instead.隐藏实际数据点而人为地显示偶数点是不诚实的。 It misleads the viewer as to where the curve is reliable and where it may not be.它会误导观察者曲线在哪里可靠,在哪里可能不可靠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM