首页 > 解决方案 > 如何从 .csv 文件镜像和重复周期函数

问题描述

我有几个具有一半对称周期函数的 .csv 文件。绘制文件、镜像文件然后重复原始和镜像直到 x_range 结束的最佳方法是什么?编辑:现在我意识到如何做到这一点,但如果有更优雅的方式来做到这一点,我仍然很感兴趣。

stats "KWV [100] прод.DAT" using 1 name "A"
stats "KWV [111] прод.DAT" using 1 name "B"
stats "KWV [100] поп.DAT" using 1 name "C"
stats "KWV [111] поп.DAT" using 1 name "D"
plot for [i = 0:3] "KWV [100] прод.DAT" using (i*2*A_max+ $1):2 with lines lc "green" notitle,for [i = 0:3] "KWV [100] прод.DAT" using ((i*2+2)*A_max-$1):2 with lines lc "green" notitle, keyentry with lines lc "green" title "[100] Продольные", for [i = 0:3] "KWV [111] прод.DAT" using (i*2*B_max+$1):2 with lines lc "red" notitle,for [i = 0:3] "KWV [111] прод.DAT" using ((i*2+2)*B_max-$1):2 with lines lc "red" notitle, keyentry with lines lc "red" title "[111] Продольные", for [i = 0:3] "KWV [100] поп.DAT" using (i*2*C_max+$1):2 with lines lc "blue" notitle,for [i = 0:3] "KWV [100] поп.DAT" using ((i*2+2)*C_max-$1):2 with lines lc "blue" notitle, keyentry with lines lc "blue" title "[100] Поперечные", for [i = 0:3] "KWV [111] поп.DAT" using (i*2*D_max+$1):2 with lines lc "magenta" notitle,for [i = 0:3] "KWV [111] поп.DAT" using ((i*2+2)*D_max-$1):2 with lines lc "magenta" notitle, keyentry with lines lc "magenta" title "[111] Поперечные"

标签: gnuplot

解决方案


好吧,你没有提供太多细节。取决于您到底想要什么,这可能是一种方法。

代码:

### horizontal mirroring of data
reset session

# create some test data 
# curve from here: https://mathworld.wolfram.com/HeartCurve.html
set table $Data
    plot sample [t=0:pi:0.1] '+' u (16*sin(t)**3 + 3):(13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)) w table
unset table

set size ratio -1
set xrange [-25:25]
set grid xtics, ytics
xm = 3   # mirror axis

plot $Data u 1:2 w lp pt 7 lc "red" title "Original", \
     '' u (-($1-xm)+xm):2 w lp pt 7 lc "green" title "Mirror"
### end of code

结果:

在此处输入图像描述


推荐阅读