Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #4420 > unrolled thread
| Started by | Jörg Buchholz <bookwood4new@freenet.de> |
|---|---|
| First post | 2021-07-13 14:11 +0200 |
| Last post | 2021-07-14 07:07 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.graphics.apps.gnuplot
plot for [i = 'list of numbers'] Jörg Buchholz <bookwood4new@freenet.de> - 2021-07-13 14:11 +0200
Re: plot for [i = 'list of numbers'] Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2021-07-13 14:37 +0200
Re: plot for [i = 'list of numbers'] Jörg Buchholz <bookwood4new@freenet.de> - 2021-07-14 07:07 +0200
| From | Jörg Buchholz <bookwood4new@freenet.de> |
|---|---|
| Date | 2021-07-13 14:11 +0200 |
| Subject | plot for [i = 'list of numbers'] |
| Message-ID | <scjvsl$9af$1@dont-email.me> |
Hello,
I have a dataset with 10 columns. First I will plot most of them and I use:
plot for [i = 3:10] 'file' skip 6 u 2:i w l t sprintf("T_%i",i-2)
in a second plot I will plot only column 6,8 and 9. Is there a way to
use a list of numeric or only a list of strings.
Plot for [i = 6, 8, 9] 'file' skip 6 u 2:i w l t sprintf("T_%i",i-2)
or
list = "6 8 9"
plot for [i in list] 'file' skip 6 u 2:i w l t sprintf("T_%i",i-2)
Does not work. A solution that works is the following, but it is little
more work.
plot for [i = 6:8:2] 'file' skip 6 u 2:i w l t sprintf("T_%i",i-2),\
for [i = 9:9] '' skip 6 u 2:i w l t sprintf("T_%i",i-2)
Jörg
[toc] | [next] | [standalone]
| From | Hans-Bernhard Bröker <HBBroeker@t-online.de> |
|---|---|
| Date | 2021-07-13 14:37 +0200 |
| Message-ID | <il5fo7Fg9ehU1@mid.dfncis.de> |
| In reply to | #4420 |
Am 13.07.2021 um 14:11 schrieb Jörg Buchholz:
> list = "6 8 9"
> plot for [i in list] 'file' skip 6 u 2:i w l t sprintf("T_%i",i-2)
Close, but no cigar. The string-based list does not work like that
because its elements evaluated by the for loop are still strings.
The following would have worked, though:
plot for [i in "6 8 9"] 'file' u 2:int(i)
The following may be more useful. See "help arrays" to understand what
it does:
n = 3
array list[n] = [6, 8, 9]
plot for [i in 1:n] 'file' u 2:list[i]
[toc] | [prev] | [next] | [standalone]
| From | Jörg Buchholz <bookwood4new@freenet.de> |
|---|---|
| Date | 2021-07-14 07:07 +0200 |
| Message-ID | <sclrdq$b3r$1@dont-email.me> |
| In reply to | #4421 |
On 13.07.2021 14:37, Hans-Bernhard Bröker wrote:
> Am 13.07.2021 um 14:11 schrieb Jörg Buchholz:
>
>> list = "6 8 9"
>> plot for [i in list] 'file' skip 6 u 2:i w l t sprintf("T_%i",i-2)
>
> Close, but no cigar. The string-based list does not work like that
> because its elements evaluated by the for loop are still strings.
>
> The following would have worked, though:
>
>
> plot for [i in "6 8 9"] 'file' u 2:int(i)
>
> The following may be more useful. See "help arrays" to understand what
> it does:
>
> n = 3
> array list[n] = [6, 8, 9]
> plot for [i in 1:n] 'file' u 2:list[i]
>
>
Thanks a lot. At the moment I prefer your first solution, cause I
understood it "out of the box".
Jörg
[toc] | [prev] | [standalone]
Back to top | Article view | comp.graphics.apps.gnuplot
csiph-web