gnuplotpoints

How set point type from data in gnuplot?


How set point type from data in gnuplot?

gnuplot script:

set terminal pngcairo size 640,480
set output "points.png" 
set style data points 
set auto x 
set autoscale x 
unset colorbox 
plot 'test.data' using 2:1 with points notitle

test.data

32  35  8
34  34  6
36  28  1
34  32  2
28  30  7
38  30  9
34  29  2
35  36  9
39  34  3
31  33  9
28  31  6
35  30  5
33  41  4
32  37  3

how get point type from 3 column?

plot 'gnuplot.data' using 2:1 with points pt (:3) notitle // error 

abstraction example:

enter image description here

need:

enter image description here

gnuplot Version 4.6 patchlevel 4


Solution

  • There is no option to select the point type from the data file based on a column (equivalent to linecolor variable, pointsize variable or arrowstyle variable). Basically you have two options:

    1. Iterate over all possible point types (which you can extract with stats if this should be variable) and for each number plot only those points which match the current point type:

      stats 'test.data' using 3 nooutput
      unset key
      set style data points
      plot for [i=STATS_min:STATS_max] 'test.data' using 2:($3 == i ? $1 : 1/0) lt 1 pt i ps 2
      

    enter image description here

    1. Use the labels plotting style and a sequence of unicode point symbols from which you select using the value from the third column as index. (use e.g. http://www.shapecatcher.com or http://decodeunicode.org/en/geometric_shapes to find suitable symbols)

      unset key
      set encoding utf8
      symbol(z) = "•✷+△♠□♣♥♦"[int(z):int(z)]
      plot 'test.data' using 2:1:(symbol($3)) with labels textcolor lt 1
      

    enter image description here