5

I want to plot points, each with X, Y and a color. How do I do that in Gnuplot?

2 Answers 2

10

You can try something like this:

Line plot in GnuPlot where line color is a third column in my data file?

For example:

plot "./file.dat" u 1:2:3 with points palette

where file.dat contains your data, the first column is the x axis and the second column is the y axis, the third column is the colour.

Sign up to request clarification or add additional context in comments.

Comments

3

You could consider looking at the Pyxplot plotting package http://pyxplot.org.uk, which has very similar syntax to gnuplot (albeit cleaned up considerably), and which allows point styles to be specified on a point-by-point basis. For example, in Pyxplot:

plot "file.dat" using 1:2:3 with points color rgb($4,$5,$6)

would take the RGB components for the color of each point from the 4th, 5th and 6th columns of the data file. Alternatively,

plot "file.dat" using 1:2:3 with points color $4

would read the numbers in the 4th column of the data file (call it n), and plot each point with the n-th color from the palette. If n is non-integer, say 2.5, it gives you a color half way between color 2 and color 3 in RGB space.

1 Comment

The syntax is quite different from gnuplot. In gnuplot you can't do color rgb(r,g,b).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.