Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I plot 2-dimensional data in circles where radius representing the 3rd column and the color representing the 4th column?

Tags:

colors

gnuplot

Here is an example data set.

#x y r c
1 2 10 2
3 1 2 4
3 2 1 5

I can plot with circle's radius representing the 3rd column OR with color representing the 3rd column. However, I don't know how to keep them both in the plot.

Here is my code to plot with radius representing the 3rd column.

plot 'rslt.log' u 1:2:3 w points pt 7 ps variable
like image 707
SenSnail Avatar asked Oct 05 '22 16:10

SenSnail


2 Answers

Try:

plot 'rslt.log' u 1:2:3:4 w points pt 7 ps variable lc palette
like image 86
andyras Avatar answered Oct 10 '22 02:10

andyras


An alternative is:

plot 'test.dat' u 1:2:3:4 w p pt 7 ps variable lc variable

or using the circles linestyle:

plot 'test.dat' u 1:2:3:4 w circles linecolor variable 

If you want solid filled circles:

plot 'test.dat' u 1:2:3:4 w circles linecolor variable fillstyle solid

For any of the above, you can substitute linecolor variable with linecolor palette as suggested by @andyras. The difference is that palette maps a floating point number onto the palette whereas variable maps the integer to a linestyle which has a color associated with it.

With ps variable the number in the associated column becomes a multiplicative factor which increases the default size of the point. With circles you have the freedom to specify the exact size of the circle (as the radius) -- Although I'm not 100% sure which axis is used in the common case where the aspect ratio of your plot isn't 1.

like image 42
mgilson Avatar answered Oct 10 '22 02:10

mgilson