Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot: Setting the range of a third (colored) point

Tags:

gnuplot

When plotting 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? say I want the range of the 3rd point to be from 0 to 1500.

Any suggestions?

like image 638
stupidity Avatar asked Jun 13 '12 09:06

stupidity


1 Answers

This is actually a really good question -- assuming you mean that you want the colorbar range to be determined (not the legend [i.e. key] -- the legend doesn't typically have that information).

My first thought was set cbrange. This might do what you want --

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

However, the question is then "What do you want to happen to out of range points?" This solution will move out of range points to the bottom/top of the scale (e.g. purple for negative numbers, red for numbers greater than 1500). My next thought was that you should be able to clip those points out by set zrange [0:1500] -- But that doesn't work. You have at least 2 options at this point.

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 w p pt 7 palette

Your borders will be slightly different than they were before, but that's no real big deal.

Option 2: filter with the ternary operator (which you already know about from your 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)) w p pt 7 palette

Also, for plotting color maps, you may want to look into the pm3d plotting style (image might work too). You might need to restructure your datafile slightly, but plotting color maps is that plotting style's bread-and-butter.

like image 153
mgilson Avatar answered Nov 10 '22 07:11

mgilson