Reputation: 348
I am using gnuplot to display the received signal strength of some small transmitters I'm testing.
The data I'm gathering has the latitude, longitude and RSSI (received signal strength indicator).
Sample data:
-33.77432033,151.0664296,-49
-33.7743059,151.0665004,-48
-33.77427705,151.0666246,-48
-33.7742775,151.0666962,-47
My function to color the values of the signal strength on the map is as follows:
rssicolor(a) = (-a <= 65 ? (255*65536) + ((-a * (255/65))*256) + 0 \
: (((255-(-a*(255/(120-65))))*65536)) + (255*256) + 0 )
For (strong signal) values from (-1 to -65) I plot from red (FF 00 00) to yellow (FF FF 00). For (weaker) values from -65 to -120 I plot in colors from yellow (FF FF 00) to green (00 FF 00).
So far so good, all these colors are plotted correctly on the map using:
plot 'gps-data.txt' using 2:1:(rssicolor($3)) notitle with points lc rgb variable
In order to plot data on top of a background I use gnuplot in multiplot mode.
A section of the final resulting image looks like this:
However, the colorbox on the right of the image shows a vastly different gradient of colors. It is determined by the function:
set cbrange [-40:-120]
set cblabel "Signal Strength (dBm)" offset 0.0,0.0
set zrange [0:1]
unset xlabel
unset ylabel
unset title
unset xtics
unset ytics
set colorbox vertical user origin 0.87,0.1 size 0.02,0.5
splot '++' u ($1):($2):(cos($1*$2)):($3) with pm3d
unset multiplot
I am not sure how I should go about changing (or even interpreting) the command that is responsible for the color scheme in the colorbox.
If I wanted a colorbox with gradient from Red-to-Yellow-to-Green do I have to provide a separate data file with colors or can I somehow modify the values in the above splot command to get that?
I looked at some of the gnuplot help files but the splot command doesn't show a lot of help. Also, studying the examples from the gnuplot website shows many different colors being used but they all seem to be picking them from a couple of standard color pallettes and I could not see one that goes from red-to-yellow-to-green.
The simplest hack would just be to make my own colorbox in another program and cut and paste it over this colorbox.
Any suggestions?
Upvotes: 1
Views: 2253
Reputation: 3765
In gnuplot creating palettes is very easy there are tons of ways. Have a look at help palette
. Among others you have the defined
mode:
set palette defined (0 'red', 1 'yellow', 2 'green')
To re-scale to appropriate range, you can use
set cbrange [your_min_value : your_max_value]
You can have a look at many examples in this github project
Upvotes: 2