1

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;

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.