How to specify labels with different types of points in Gnuplot?

Say I have data that I would like to build in the animals.txt file:

cat 5.2 1.0
cat 5.4 1.3
cat 5.2 1.2
dog 3.8 1.1
dog 3.5 1.5
dog 3.6 1.3
giraffe 1.3 9.7
giraffe 1.5 9.0
giraffe 1.4 9.9

I can create a scatter plot with labels using:

plot "animals.txt" u 2:3:1 w labels

I can also change the style of each point using something like:

plot "animals.txt" u 2:3 w points pointtype 3

Instead of using labels (which may overlap), is it possible for the dots to use different types of dots or colors for each category? (For example, "cat" will be red using pointtype 3, "dog" will be blue using pointtype 4, etc.)

I could use the “lc variable” and replace the shortcut column with colors, but for the file I am working with, there are too many different labels for me to make this easy.

+3
source share
1 answer

, .

, gnuplot awk. 3 , .

plot "<awk '{ if($1 == \"cat\") print $2,$3  }' animals.dat" u 1:2 w points title "cat", \
     "<awk '{ if($1 == \"dog\") print $2,$3  }' animals.dat" u 1:2 w points title "dog", \
     "<awk '{ if($1 == \"giraffe\") print $2,$3  }' animals.dat" u 1:2 w points title "giraffe"

- , , , script , ,

Tom

+2

Source: https://habr.com/ru/post/1791734/


All Articles