如何将数据文件格式从 Gnuplot 更改为 Tikz 错误栏

如何将数据文件格式从 Gnuplot 更改为 Tikz 错误栏

我想将 Gnuplot errorbar 数据的格式更改为 LaTeX/Tikz 格式。

例如Gnuplot格式的数据为:

5 74.92725 74.7028332590511 75.1516667409489
112.5 112.55897 112.259769398083 112.858170601917
150 149.69954 149.34363510537 150.05544489463
187.5 187.17666 186.776888667849 187.576431332151
225 224.99652 224.445862626087 225.547177373913
262.5 262.41776 261.885021624469 262.950498375531
300 292.136265549781 292.001497790752 292.271033308809
337.5 291.919651585991 291.609116120618 292.230187051365
375 291.422462501904 291.176186050372 291.668738953436
412.5 291.280355443992 290.980439760169 291.580271127815
450 291.280355443992 290.980439760169 291.580271127815

我需要的 Tikz 格式是这样的:

(75     ,74.92725 )         -=(0,74.7028332590511- 74.92725 )        +=(0, 75.1516667409489 - 74.92725 )    
(112.5  ,112.55897)         -=(0,112.259769398083- 112.55897)        +=(0, 112.858170601917 - 112.55897)    
(150    ,149.69954)         -=(0,149.34363510537 - 149.69954)        +=(0, 150.05544489463  - 149.69954)    
(187.5  ,187.17666)         -=(0,186.776888667849- 187.17666)        +=(0, 187.576431332151 - 187.17666)    
(225    ,224.99652)         -=(0,224.445862626087- 224.99652)        +=(0, 225.547177373913 - 224.99652)    
(262.5  ,262.41776)         -=(0,261.885021624469- 262.41776)        +=(0, 262.950498375531 - 262.41776)    
(300    ,292.136265549781)  -=(0,292.001497790752- 292.136265549781) +=(0, 292.271033308809 - 292.136265549781)
(337.5  ,291.919651585991)  -=(0,291.609116120618- 291.919651585991) +=(0, 292.230187051365 - 291.919651585991)
(375    ,291.422462501904)  -=(0,291.176186050372- 291.422462501904) +=(0, 291.668738953436 - 291.422462501904)
(412.5  ,291.280355443992)  -=(0,290.980439760169- 291.280355443992) +=(0, 291.580271127815 - 291.280355443992)

我已将这些结果制成表格以使其更清晰,但这对于 Tikz 来说不是必需的。

我有很多这种类型的文件,我想知道是否有任何命令可以使它更容易。

问候

答案1

尝试类似的方法:

awk '{printf("(%s, %s) -=(0, %s-%s) +=(0, %s-%s)\n",$1,$2,$3,$2,$4,$2)}'

甚至:

for a in *.gnudata
do
   awk '....' "$a" > "$a".tikzdata
done

相关内容