How do I use a data parameter to set the colour of gnuplot points? - colors

I'm creating a GIF of the movement of random particles and I want to plot the particles as points of a certain colour that relates to the velocity of the particle at a given time. Using gnuplot 4.6.6, how do I make the colour of a point a function of a data value? If possible, I'd like the colours to come from the palette 'rgbformula 21,22,23' and not just from the standard line colours set.
Thanks

You can use the lc palette flag:
set palette rgbformulae 21,22,23
plot 'particles.dat' using 1:2:3 lc palette
type ? linecolor or ? palette for more info.

You can pass a third column to the plot command and linecolor palette. Then, the palette colors are used to encode the value of the third column and the colorbox showing the palette is drawn:
set palette rgbformula 21,22,23
plot "data" using 1:2:3 with points linecolor palette

Related

How to mange colors for contour map?

I want to plot contour maps using Gnuplot.
I tried using the following command,
set palette rgbformulae 33,13,10
splot filename u 1:2:3
This is the image file I got using those commands.
But I want to give a white color scheme when the third column has a maximum value. How to do this?
There many, many options for palette choice. Without going into all of them, I suggest you try set palette cubehelix
That provides a color range from dark to white. Here is the output from
set palette cubehelix
test palette

Gnuplot - Multiplot autoscale displays x-axis and y-axis units twice on each other

In Gnuplot I want to display 2 plots on the same graph with the help of multiplot. The display works fine, but the scaling redisplays and the same units are put on each other, because i use autoscale.
My question is, how do i display the scaling only once?
Here is my code:
set border 1023-128
set autoscale
set multiplot
plot strDsDir.strInputFile using 1:($6/1000000) skip 1 w filledcurves x lc rgb "#00aa22"
replot strDsDir.strInputFile using 1:($7/1000000) skip 1 w filledcurves x lc rgb "#80e45f"
unset multiplot
I tried unsetting autoscale, between the "plot" and "replot", but then I lose autoscaling, and graphs slip.
I also tried unsetting xtics and ytics, but then i lose the set border 1023-128 above.
Here is the picture, where my units lapse on eachother :
And here is the picture, where units dont lapse on each other, but my "set border option" disappears :
The dataset what im trying to display doesnt matter.
Thank you.
The purpose of multiplot usually is to plot several plots beside each other. If you want to plot several curves in a single plot, use a single plot command like plot x, x**2:
plot strDsDir.strInputFile using 1:($6/1e6) skip 1 w filledcurves x lc rgb "#00aa22", \
"" using 1:($7/1e6) skip 1 w filledcurves x lc rgb "#80e45f"

Gnuplot bar diagram different color with value on top of bar

My data set is simple:
CPU 5.7
Memory 3.7
I want to plot a simple bar diagram with different colors for each value and the corresponding values should be shown on top of each bar. I also want to plot the ylabel and the legend. It should almost look like the the following diagram:
Is this possible in gnuplot? There seems to be hardly any document for doing this in gnuplot. Plotting bars with historgram seems easy but styling with different colors, the value on top and the legends part is turning out to be a bit tricky for me. Can someone please help me?
Thanks in advance.
Maybe the following comes quite close:
This is the gnuplot script:
set terminal pngcairo
set output "data.png"
set title "CPU and Memory"
set nokey
set boxwidth 0.8
set style fill solid
set xrange [-1:2]
set xtics nomirror
set yrange [0:7]
set grid y
set ylabel "Time"
plot "data.dat" using 0:2:3:xtic(1) with boxes lc rgb var ,\
"data.dat" using 0:($2+0.5):2 with labels
The pseudo column 0, which is the current line number, is used as x value.
I have added a third column to your data which contains the color as rgb value.
The value on top of the bars is printed by the with labels command. It requires a using with three values: x, y, string. The part ($2+0.5) takes the y-value from the second column and adds 0.5.
The identifiers "CPU" and "Memory" are printed below the corresponding bar instead of using a separate key.
And this is the modified datafile:
CPU 5.7 0x4472c4
Memory 3.7 0xed7d31

Change color of dgrid3d surface in Gnuplot

Is there a way to change the color of the lines of the surface when using dgrid3d? It seem simple enough but everything I've looked at only speaks of coloring the whole surface using pm3d. I have multiple surfaces on one plot and would like to be able to specify the color of each. For example, one would be red, another would be blue, another would be black, another would be green.
If you have your data available in a file Data.dat then give this a try:
set dgrid3d 10,10
set style data lines
set pm3d
splot "Data.dat" pal
The dgrid3d tells gnuplot how many entries there are in the x- and
y-direction (those are the two comma separated parameters)
The style data lines lets gnuplot plot the result with lines
instead of points
The pm3d fills the surface with a color (if you leave this away you
will just see the lines)
pal makes the lines appear in the color of the specified value
There are much more options you can set, but i find those the most relevant.
Seems like.
set dgrid3d
splot "file.dat" with lines linecolor 4
Where 4 is color you need.
For multiple surfaces you can try
set dgrid3d splines
set table "surface1.dat"
splot "file1.dat"
unset table
unset dgrid3d
for every surface you need.
And after all surface description
splot "surface1.dat" with lines linecolor 4, splot "surface2.dat" with lines linecolor 7 ...

GNUPLOT: How to set reverse HOT color palette

Here is the example in http://gnuplot.sourceforge.net/demo/pm3dcolors.html
set palette rgb 21,22,23; set title "hot (black-red-yellow-white)";
The above code set the hot palette. However I want a reversed hot palette, say:
white-yellow-red-black.
Small least value map to white and largest value map to black.
Miguel's answer is correct. Rather than making the individual numbers negative, the command set palette negative also does the trick:
set pm3d map
set palette negative rgb 21,22,23
splot x
would produce what you wanted. You can split the command up too:
set palette rgb 21,22,23
set palette negative
is equivalent. You can use set palette positive to undo this modification, or set palette to restore all the defaults (including the colours). Try help set palette for the full list of things you can do.
Use negative numbers to invert the palette:
set pm3d map
set palette rgb 21,22,23
splot x
gives you
whereas
set pm3d map
set palette rgb -21,-22,-23
splot x
gives you

Resources