1

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:

I know, it's not properly aligned

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?

0

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

I am stumped. This is perfect and so elegant! I immediately used some of my own colors and have it exactly the way I wanted. I did come across the gnuplotting.org website but I was unable to find what I was looking for. The github site correctly demonstrates what is required. Thank you so much! I do have another question regarding background image color distortion but I'll post that in another question and hope you'll be able to shed some light on the matter again.
what does 0, 1 and 2 mean here? please.. @bibi
the min and max are arbitrary, but not the ration of the others with respect to them. For exemple 0,1,2 would be equal to 0,0.5,1 or 0,50,100 or -1,0,1 or 0,4,8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.