Search code examples
plotgnuplot

How to use GnuPlot to create a plot of droplets of size d versus height and color the droplets by size?


I have a file of x,y,z,d Where x,y,z are the coordinates of a droplet and the diameter of the droplet is d.

I want to do a GnuPlot of the x, z position of the droplet and color it by the diameter from the RGB spectrum scaled from the minimum d to the maximum d.

I have tried using this:

unset hidden3d
set ticslevel 0.5
set view 60,30
set autoscale
set parametric
set style data points
set xlabel "data style point - no dgrid"
set key box
set output 'particles.png'
plot '/directory/kinematicCloud_00000490.dat' \
 using 1:3:(0.5-rand(0)):(5.*rand(0))  with points pt 5 ps var lc rgb variable
pause -1

But, the points are being colored here by random colors. I'd like them colored as I said above. So, how do I specify the 3rd and 4th argument to do what I wish?


Solution

  • # Set palette to RGB spectrum (Red = Min; Blue = Max)
      set palette model HSV defined (0 0 1 1, 1 0.7 1 1)
    # Set min/max of color spectrum to match expected droplet size
      set cbrange [0 : MAX]
    
    # 3D plot with points colored by diameter
      splot 'data' using 1:2:3:4 with points pointtype 7 lc palette
    

    enter image description here

    If you want to discard the y coordinate and make a 2D plot instead, then the command becomes

    # 2D plot x/z with points colored by diameter
      set view map
      splot 'data' using 1:3:(0):4 with points pointtype 7 lc palette
    

    enter image description here