Score:0

Loop structure inside gnuplot command

tr flag

I am trying to use for loop for this big gnuplot plot command

plot -22.5 lw 3,22.5 lw 3,\                     
    'hydro_0/hydro_0.01/tracer_com.dat' u (($2)**2+($3)**2)**0.5:4 w lw 2 lc 1,\
    'hydro_0/hydro_0.02/tracer_com.dat' u (($2)**2+($3)**2)**0.5:4 w lw 2 lc 2,\
    'hydro_0/hydro_0.03/tracer_com.dat' u (($2)**2+($3)**2)**0.5:4 w lw 2 lc 3,\
    'hydro_0/hydro_0.04/tracer_com.dat' u (($2)**2+($3)**2)**0.5:4 w lw 2 lc 4,\
    'hydro_0/hydro_0.05/tracer_com.dat' u (($2)**2+($3)**2)**0.5:4 w lw 2 lc 5

I am using for loop to avoid such long texts

plot for [i=01:20] -22.5 lw 3,22.5 lw 3, "hydro_0/hydro_0.".i"/tracer_com.dat" u (($2)**2+($3) w lw 2 lc .i

It is showing error:

internal error : STRING operator applied to undefined or non-STRING variable

Can anyone please help me in fixing this gnuplot plot syntax?

hr flag
I see 2 issues here (1) missing the second string concatenation operator (**after** the variable `i`) and (2) afaik numeric variables don't retain their zero padding automatically. You should probably use a `sprintf` instead ex. `sprintf("hydro_0/hydro_0.%02d/tracer_com.dat",i)`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.