I have this iris data ...
5.1 3.5 1.4 0.2 Iris-setosa
4.9 3 1.4 0.2 Iris-setosa
7 3.2 4.7 1.4 Iris-versicolor
6.4 3.2 4.5 1.5 Iris-versicolor
7.1 3 5.9 2.1 Iris-virginica
6.3 2.9 5.6 1.8 Iris-virginica
.
.
.
and I got graph using gnuplot (plot 'c:\iris.data')
But I want points with color group by 5th column (iris-setosa, iris-versicolor, iris-virginica)
For example . . .
iris-setosa = color red, iris-versicolor= color green, iris-virginica = color blue
How can I get color graph?
Please answer . . . .
Replace your colours with numerical indices, e.g., like this:
5.1 3.5 1.4 0.2 0
4.9 3 1.4 0.2 0
7 3.2 4.7 1.4 1
6.4 3.2 4.5 1.5 1
7.1 3 5.9 2.1 2
6.3 2.9 5.6 1.8 2
A simple search-and-replace script should be able to do this for you.
Then you can use Gnuplot’s linecolor palette
, e.g. as follows:
plot "iris.data" u 1:2:5 w p lc palette
To adjust the colours used like this:
set palette defined (0 "red", 1 "green", 2 "blue")
Note that while I chose to use the exact indices here, the palette definition is relative and I might as well have used:
set palette defined (-11 "red", -2 "green", 7 "blue")