There are several ways to do that:
You can define several line style and then use linecolor variable
, which allows you to use the last column as line style index:
set timefmt '%Y-%m-%d'
set xdata time
set format x '%Y-%m'
set style increment user
set style line 1 lc rgb 'red'
set style line 2 lc rgb 'blue'
set style line 3 lc rgb 'green'
set style line 4 lc rgb 'magenta'
set style line 5 lc rgb 'yellow'
set style data points
plot 'data.txt' using 1:2:3 linecolor variable pt 7 ps 2 t ''
The result is:

This requires you to define as many line styles as you have colors.
Alternatively you can define a respective color palette and use linecolor palette
to do the coloring of the points:
set timefmt '%Y-%m-%d'
set xdata time
set format x '%Y-%m'
set cbrange [1:6]
set palette defined (1 'red', 3.5 'red', 3.5 'green', 6 'green')
set style data points
unset colorbox
plot 'data.txt' using 1:2:3 linecolor palette pt 7 ps 2 t ''
When using this, you must pay attention, that the cbrange
and the values used for the palette defined
match (here 1
and 6
), because in general the values of the palette are adapted to match the color range.
The above script gives the result:
