Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can't plot colours from a datafile

187 views
Skip to first unread message

geep

unread,
Dec 18, 2009, 8:04:34 AM12/18/09
to
Hi,
I can't plot colours from a datafile. with gnuplot 4.4 patchlevel 0-rc1
The manual of Gnuplot 4.4 in 16.1.2 says:
#Use the third column of data to assign colors to individual points
plot 'data' using 1:2:3 with points lc variable

My data is like this:
156 65 "black"
160 77 "black"
159 78 "black"

I also tried like this:
156 65 black
160 77 black
159 78 black

I get this error:
gnuplot> plot 'data' using 1:2:3 with points lc variable
^
warning: Skipping data file with no valid points
^
x range is invalid

But the same file plots OK like this:
gnuplot> plot 'data' using 1:2 with points

Then all the points are defaulted to red.

Can anybody tell me what I'm doing wrong?

Cheers,
Peter

Péter Juhász

unread,
Dec 18, 2009, 11:59:17 AM12/18/09
to

The syntax you are trying to use is for specifying the _color index_
of the point/line.
That is, plotting the following data with your first plot command:
156 65 11
160 77 22
159 78 33

will result in the first point plotted with the 11th defined color,
the second with the 22nd and the third with the 33rd - whatever those
may be. (These colors are also terminal-dependent.)

What you want is achieved by the following syntax:

plot 'data' using 1:2:3 with points lc rgbcolor variable

And in this case the colors need to be specified as 24 bit integers.
As far as I can tell, color names like "black" are not supported.

In certain circumstances (gnuplot built with a C library that can read
hex numbers?) you can specify those 24 bit integers in hexadecimal,
for example:
156 65 0xff0000
160 77 0x00ff00
159 78 0x0000ff

Plotting this with the plotting command above will result in a red,
blue and green point on the plot.

Péter Juhász

geep

unread,
Dec 18, 2009, 1:14:07 PM12/18/09
to

Thanks Péter. Now I understand.
I've now specified hex colours and it plots OK.

Cheers,
Peter

0 new messages