0

I have multiple .txt files of the naming order

rp_sub-pilote3b_Phase1_Basis_a.txt rp_sub-pilote3b_Phase1_Basis_b.txt
rp_sub-pilote3b_Phase1_Basis_a.txt rp_sub-pilote3b_Phase1_Basis_b.txt
rp_sub-pilote3b_Phase1_Basis_a.txt rp_sub-pilote3b_Phase1_Basis_b.txt
rp_sub-pilote3b_Phase1_Basis_a.txt rp_sub-pilote3b_Phase1_Basis_b.txt

I want to create 4 plots corresponding to each phase. In each of these, I want to plot the first 3 columns from *_Basis_a.txt and *_Basis_b.txt corresponding to that phase. I have the following code, but it produces the error line 20: internal error : STRING operator applied to undefined or non-STRING variable

#load this this with  "./gnuplot.txt"
#set terminal qt enhanced 40


set terminal postscript enhanced color solid  "Helvetica" 10
set out "motion_translation.ps"
set key left bottom # for Position of Legend

set title "Motion across timesteps"   font "Helvetica,10"
set ylabel "displacement in mm"  font "Helvetica,10"
set xlabel "|time in TR"  font "Helvetica,10"
set size ratio 0.6

do for [n=1:4]{
    plot    sprintf("rp_sub-pilote3b_Phase.%d._Basis_a.txt", n) using 0:1  with lines lw 3  title "Not nulled x"  linecolor rgb "green" ,\
        sprintf("rp_sub-pilote3b_Phase.%d._Basis_a.txt", n) using 0:2  with lines lw 3 title "Not nulled y"  linecolor rgb "red" ,\
        sprintf("rp_sub-pilote3b_Phase.%d._Basis_a.txt", n) using 0:3  with lines lw 3 title "Not nulled z"  linecolor rgb "brown" ,\
        sprintf("rp_sub-pilote3b_Phase.%d._Basis_b.txt", n) using 0:1  with lines lw 3 title "nulled x"  linecolor rgb "turquoise" ,\
        sprintf("rp_sub-pilote3b_Phase.%d._Basis_b.txt", n) using 0:2  with lines lw 3 title "nulled y"  linecolor rgb "pink" ,\
        sprintf("rp_sub-pilote3b_Phase.%d._Basis_b.txt", n) using 0:3  with lines lw 3 title "nulled z"  linecolor rgb "black"
}
1
  • I can't reproduce your problem. For me, do for [n=1:4] {print sprintf("rp_sub-pilote3b_Phase.%d._Basis_a.txt", n)} gives proper output (same for the other lines). Commented Mar 16, 2022 at 16:49

1 Answer 1

1

Can't reproduce your problem exactly, my gnuplot version 5.4.1 shows another error message:

line 20: duplicated or contradicting arguments in plot options

This can be solved by putting the arguments for plot in the correct order - title before with:

... using 0:2 title "Not nulled y" with lines lw 3 linecolor rgb "red" 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, moving title before with worked.

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.