Reputation: 568
how can I use gnuplot to plot isolated points(not connected points): the x axis must be the first column which is the date, the y axis is the second columns the 3rd column must be the color of the point(colors are defined into ranges (ex: from 1 to 3 red, from 4 to 6 green...)
1999-01-19 21 0
2009-07-01 0 1
2008-08-20 2 1
2008-12-18 1 1
2004-05-12 4 1
2009-07-29 2 1
2008-08-07 0 1
2006-03-08 1 1
2004-08-31 9 2
2001-03-27 12 2
2009-08-19 0 2
2010-07-14 2 3
2009-06-24 4 3
2009-11-11 33 4
2010-10-13 5 4
2012-02-22 34 4
2011-05-11 2 5
Upvotes: 1
Views: 6455
Reputation: 48390
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:
Upvotes: 1
Reputation: 3612
Some solution could be:
plot for [i=0:5] 'cp.txt' using ( i==$3 ? $1 : 1/0 ):2 notitle with points linestyle i
Upvotes: 0