Warm tip: This article is reproduced from stackoverflow.com, please click
gnuplot

Define pointtype using `word` command in gnuplot

发布于 2020-03-28 23:14:58

I am plotting several datafiles using the same linestyle (ls 1). However, I would like to differentiate the data using different pointtypes contained in wrd_pt on the code below.

The result is shown in the figure, where GNUPLOT plots as pointtype the values contained into the variable wrd_pt instead of the symbols (square, triangle, ...) associated with each numbers. I am using GNUPLOT 5.0 and there is no way I can update it (I am not the sudoer of the computer I am using) to use arrays for e.g. of the version 5.2.

Does anyone knows how I can fix that?

[... initializing ...]
wrd_pt ="5 7 9 11 13 15"
[... some other piece of code ...]
set output "plot_1a.eps"
    plot for [i=1:words(fspo_one)] work_dir.word(fspo_one, i) u 1:5 w lp ls 1 pt word(wrd_pt, i) ps 1 notitle
unset output 

Result of the code

Questioner
many
Viewed
48
theozh 2020-01-31 18:05

Why not using plotting style with labels? Works also with gnuplot 5.0.

Something like this:

Code:

### point types as string from a string
reset session

wrd_pt = "5 7 9 11 13 15"

set xrange[0:10]
set style textbox opaque

set samples 10
plot for [i=1:words(wrd_pt)] '+' u 1:(i*$1**2) w l lw 2 notitle, \
     for [i=1:words(wrd_pt)] '+' u 1:(i*$1**2):(word(wrd_pt,i)) w labels boxed notitle

### end of code

Result:

enter image description here