gnuplot with muliple columns using loop

我与影子孤独终老i 提交于 2019-12-11 06:21:43

问题


I have a number of files (having 10 columns each) with following order:

file_001.txt, file_002.txt, file_003_txt,
file_021.txt, file_023.txt, file_023.txt,
file_041.txt, file_042.txt, file_043.txt,
file_061.txt, file_062.txt, file_063.txt,
file_081.txt, file_082.txt, file_083.txt,

I would like to plot each file with different line. e.g. using 1:2, using 1:3, using 1:5, using 1:8. I can not able to make a loop to call different columns. My following script is not working for k field

 plot for [k=2, 3, 5, 8] for [j=0:8:2] for [i=1:3] 'file_0'.j.i.'.txt' u 1:k;

回答1:


Use for [k in "2 3 5 8"] if you have a list rather than a range.




回答2:


If j can be > 9, you should set up a function

fname(j,i) = sprintf("name%02.f%.f",j,i)

to get proper file names.

Format string "%02.f" means float (f), no digits after the comma (.), minimum two postions (2), fill empty space with zeroes.

print fname(2,3)
    name023

print fname(13,3)
    name133

print fname(113,3)
    name1133

These are libc format strings, they are not documented inside the gnuplot docs, but there are many sources in the web.



来源:https://stackoverflow.com/questions/37151871/gnuplot-with-muliple-columns-using-loop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!