Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to color points with a color declared in a data column with format `#aabbcc` in Gnuplot?

I'm using Gnuplot to make a scatterplot from my data that consists of 5 items:

index, name, x value, y value, color (#12e335)

The color is different for each entry. Is there a way to make the color of my datapoint (x,y) get the color that is listed in the data?

Is it possible in this format for color (#aabb12), or do I need to change to format for gnuplot specific? It is very important that the point color is the same as the color specified in the data, since I use the same colors for a pie-chart later on (not gnuplot).

Any help would be appreciated.

like image 801
Tcanarchy Avatar asked Dec 21 '13 13:12

Tcanarchy


People also ask

How do I change the color of a data point in excel based on value?

Right click the data series on the chart and choose Format Data Series, Marker Fill, and check Vary Color by point. Was this reply helpful?


1 Answers

I found the answer myself, after a good hard look.

This line should be at the beginning of your file, right under reset or somewhere around there

 rgb(r,g,b) = int(r)*65536 + int(g)*256 + int(b)

And this is your plotting command

 plot "output.txt" using 4:5:(rgb($9,$10,$11)) \
       with points pt 7 ps 2 lc rgb variable notitle

So basically, you make a new variable rgb with 3 variables, the red, the green and the blue component. For my problem, i had to add 3 columns to my data files that described my color. So if my color was #5535cf (i calculate the colors randomly) my rgb value would be (85, 53, 207) I would then add 3 columns to my output.txt data file with 85, 53 and 207.

These numbers are in column 9, 10 and 11 from my output file, which explains the $9 $10 and $11. There should be the columnnumbers where your r g and b values are.

If you add lc rgb variable notitle to your plot command, the points should take the color you assigned them in your data-file.

Hope this helps a lot of people!

like image 111
Tcanarchy Avatar answered Nov 15 '22 09:11

Tcanarchy