Gnuplot: setting the range of the third (color) point

When building color maps using gnuplot, I usually use the following lines:

... set palette rgbformulae 33,13,10 plot "file.dat" using 1:2:3 with points pointtype '7' palette 

Usually the range of the third point (appearing in the legend) is automatically set by gnuplot. But how can I change that? let's say I want the range of the 3rd item to be between 0 and 1500.

Any suggestions?

+7
source share
1 answer

This is actually a really good question - if you want you to define a range of color bars (and not a legend [for example, a key] - a legend usually does not have such information).

My first thought was set cbrange . It can do what you want -

 set cbrange [0:1500] set palette rgbformulae 33,13,10 plot "file.dat" u 1:2:3 wp pt 7 palette 

However, the question arises: "What do you want to get out of range?" This solution will move out of range to the bottom / top of the scale (for example, purple for negative numbers, red for numbers greater than 1500). My next thought was that you should be able to crop these points set zrange [0:1500] - but that will not work. You currently have at least 2 options.

Option 1: use splot:

 set view map set cbrange [0:1500] set zrange [0:1500] set palette rgbformulae 33,13,10 splot "file.dat" u 1:2:3 wp pt 7 palette 

Your boundaries will be slightly different from the previous ones, but this does not really matter.

Option 2: a filter with a ternary operator (which you already know about from the previous question):

 set cbrange [0:1500] set palette rgbformulae 33,13,10 inrange(c)=((c>=0) && (c<=1500))? c : (1/0) plot "file.dat" u 1:2:(inrange($3)) wp pt 7 palette 

In addition, to build color maps you may need to study the pm3d build pm3d ( image may work too). You may need to change the structure of your data file a little, but building color maps is building a bread-and-butter style.

+11
source

All Articles