Rod_Algonquin
Rod_Algonquin

Reputation: 26198

Customize color ranges in Gnuplot

I have a contour plot running just fine and it is generating an equal amount of color for different values.

What I want is to generate the label on the right side to have a right color for each block.

current result:

enter image description here

What I want is to have this value on each block:

---- 300

---- 100

---- 70

---- 30

---- 10

---- 1

---- 0

Edit: When I add this code:

set cbtics ('300' 300, '100' 100, '30' 30, '10' 10, '1' 1, '0.5' 0.5, '0.1' 0.1, '0.01' 0.01, '0' 0);
set palette defined (0.1 "#4CAF4F",0.3 "#65B443",0.5 "#7FBA38",0.7 "#98BF2D",0.9 "#B2C521",1.0 "#CBCA16",2 "#E5D00B",3 "#FFD600",4 "#FFC400",5 "#FFB300",6 "#FFA100",7 "#FF9000",8 "#FF7E00",10 "#FF6D00",30 "#F85A00",50 "#F14800",70 "#EA3600",90 "#E32400",100 "#DC1200",300 "#D50000")

The result is a uneven:

enter image description here

I want the ticks to be even but could not make it.

Upvotes: 3

Views: 303

Answers (1)

Miguel
Miguel

Reputation: 7627

I would recommend that you rescale your output from the scale 0 to 300 to a scale in which the values vary linearly between the manually defined labels on the color bar:

rescale(x) = ( x >= 0. && x < 1. ? x : \
               x >= 1. && x < 10. ? 1.+(x-1.)/(10.-1.) : \
               x >= 10. && x < 30. ? 2.+(x-10.)/(30.-10.) : \
               x >= 30. && x < 70. ? 3.+(x-30.)/(70.-30.) : \
               x >= 70. && x < 100. ? 4.+(x-70.)/(100.-70.) : \
               x >= 100. && x < 300. ? 5.+(x-100.)/(300.-100.) : \
               1/0)
set cbrange [0:6]
set cbtics ("0" 0, "1" 1, "10" 2, "30" 3, "70" 4, "100" 5, "300" 6)
set pm3d
splot rescale(x**2+y**2)

enter image description here

If you want to limit the colors to one per block, add the following line:

set palette maxcolors 6

enter image description here

Finally, note that if you have a map the labeling is sufficient as is. If you have a 3D plot, you might want to also relabel the z axis:

set ztics ("0" 0, "1" 1, "10" 2, "30" 3, "70" 4, "100" 5, "300" 6)

Upvotes: 6

Related Questions