3

I plot a 2D function using splot with a colour palette:

set zrange [0.5:1.5] 
set palette defined ( 0 "green", 1 "black", 2 "red" )
splot "HTSG_PeakPositions_thetaI080.gnuplot" using 3:1:5 title 'Relative Peak Positions' with pm3d

This somehow works; however, I'd like the graph to be black exactly at value 1.0 and coloured appropriately if it diverges from this level. The problem is that the palette is defined relatively to the range of min:max values contained in the plot and not to absolute values. The zrange option doesn't seem to affect this behaviour. Is there a way to create the absolute mapping?

ivokabel
  • 186
  • 4
  • 12

1 Answers1

3

The color range is affected by set cbrange:

set cbrange [0.5:1.5]
set palette defined ( 0 "green", 1 "black", 2 "red" )
splot "HTSG_PeakPositions_thetaI080.gnuplot" using 3:1:5 title 'Relative Peak Positions' with pm3d

If you want some kind of autoscaling symmetric to 1.0, you can use the stats command to determine the color range before plotting:

stats "HTSG_PeakPositions_thetaI080.gnuplot" using 5 nooutput
cb_val = (abs(STATS_min - 1) < abs(STATS_max - 1) ? abs(STATS_max - 1) : abs(STATS_min - 1))
set cbrange [1 - cb_val : 1 + cb_val]
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • This looks very similar to the problem I'm having with Gnuplot. What I'm doing is scatterplotting the atoms in molecules. Different colors for different elements with the palette defined just like above, BUT if I don't have one of those elements in the molecule, Gnuplot just rescales the whole color scheme and the molecule looks like crap. Is there a way I can nail down 1 to be a color, 2 to be a color, 3 to be a color, etc, without having to redefine the cbrange or palette for every molecule I plot? In other words, whether or not any one of those integers exist in the plot or not? – Todd Pierce Dec 22 '16 at 22:14