Thank you for your tips. But the using of word() function is limitted
to "words".
If a key title is a string with spaces, then the word() function can not
be used.
Only array function can solve the problem perfectly.
In version 4.5, the loop and block are supported as new features:
7 * NEW syntax supporting multi-line blocks of code delimited by curly
braces
8 if (<cond>) { ... } else { ... }
9 do for [...] { ... }
10 while (<cond>) { ... }
Now that loop is supportted, the absence of array will limit the
application of loop in significant measure.
So, I still highly suggest developers to add array support in the future.
gbliu
? 2011/11/19 4:30, Ethan A Merritt ??:
> On Friday, November 18, 2011 01:43:29 am gbliu wrote:
>> Dear all:
>>
>> These years gnuplot becomes more and more powerful. In sense, it's a
>> quasi-programming-language. String variable is supported since ver4.0, and {}
>> blocks and loops are supported in ver4.5. But a basic function, array, is still
>> not supported now. I think this is highly needed, especially when loops are
>> supported.
>>
>> ------------------------
>> e.g.
>>
>> I have a data file with many columns, but want to plot only some columns, say,
>> column 2, 3,6,7,9,15,24. And the lengeds for each column differ. Now, I can only
>> use the command as follow:
>>
>>
>> plot 'data' u 1:2 title '...', '' u 1:3 title '...', '' u 1:6 title '...',\
>> '' u 1:7 title '...', '' u 1:9 title '...', '' u 1:15 title '...',\
>> '' u 1:24 title '...'
>>
>> Although gnuplot support "plot for [i=...]" now, but it cannot be used here,
>> because the column numbers is not regular. In this case, array is needed to
>> simplify the plot command.
> Array support has been suggested before, but no one has stepped up to
> do the work :-)
>
> In your particular case it is possible to use the existing syntax
>
> plot for [COL in "2 3 6 7 9 15 24"] 'data' using 1:(column(int(COL))
>
> Generalizing this a little bit, you could even do
>
> COL = "2 3 6 7 9 15 24"
> TITLE = "title2 title3 title6 title7 title9 title15 title24"
>
> plot for [i=1:7] 'data' using 1:(column(int(word(COL,i)))) title word(TITLE,i)
>
>
> Ethan
>
>
>> Suppose there are two arrays, col and str:
>> col[1]=2; str[1]='...'
>> col[2]=3; str[2]='...'
>> col[3]=6; str[3]='...'
>> col[4]=7; str[4]='...'
>> col[5]=9; str[5]='...'
>> col[6]=15; str[6]='...'
>> col[7]=24; str[7]='...'
>>
>> now, I can use the following more concise command:
>>
>> plot for [i=1:7] 'data' u 1:(column(col[i])) title str[i]
>>
>> ------------------------
>>
>> Therefore, array is highly suggested to be supportted by gnuplot!
>>
>> Yours, faithfully
>>
>> gbliu
>>
>
|