I have defined the following colours and I want to use them for my densityplot.
color1 = RGBColor[0/255 , 0/255 , 0/255];
color2 = RGBColor[31.875/255 , 0/255 , 31.875/255];
color3 = RGBColor[63.75/255 , 0/255 , 63.75/255];
color4 = RGBColor[95.625/255 , 0/255 , 95.625/255];
color5 = RGBColor[127.50/255 , 0/255 , 127.50/255];
color6 = RGBColor[159.375/255 , 0/255 , 159.375/255];
color7 = RGBColor[191.25/255 , 0/255 , 191.25/255];
color8 = RGBColor[223.125/255 , 0/255 , 223.125/255];
color9 = RGBColor[255/255 , 0/255 , 255/255];
color10 = RGBColor[204/255 , 0/255 , 255/255];
color11 = RGBColor[153/255 , 0/255 , 255/255];
color12 = RGBColor[102/255 , 0/255 , 255/255];
color13 = RGBColor[51/255 , 0/255 , 255/255];
color14 = RGBColor[0/255 , 0/255 , 255/255];
color15 = RGBColor[0/255 , 31.875/255 , 255/255];
color16 = RGBColor[0/255 , 63.75/255 , 255/255];
color17 = RGBColor[0/255 , 95.625/255 , 255/255];
color18 = RGBColor[0/255 , 127.50/255 , 255/255];
color19 = RGBColor[0/255 , 159.375/255 , 255/255];
color20 = RGBColor[0/255 , 191.25/255 , 255/255];
color21 = RGBColor[0/255 , 223.125/255 , 255/255];
color22 = RGBColor[0/255 , 255/255 , 255/255];
color23 = RGBColor[0/255 , 255/255 , 204/255];
color24 = RGBColor[0/255 , 255/255 , 153/255];
color25 = RGBColor[0/255 , 255/255 , 102/255];
color26 = RGBColor[0/255 , 255/255 , 51/255];
color27 = RGBColor[0/255 , 255/255 , 0/255];
color28 = RGBColor[51/255 , 255/255 , 0/255];
color29 = RGBColor[102/255 , 255/255 , 0/255];
color30 = RGBColor[153/255 , 255/255 , 0/255];
color31 = RGBColor[204/255 , 255/255 , 0/255];
color32 = RGBColor[255/255 , 255/255 , 0/255];
color33 = RGBColor[255/255 , 229.50/255 , 0/255];
color34 = RGBColor[255/255 , 204/255 , 0/255];
color35 = RGBColor[255/255 , 178.50/255 , 0/255];
color36 = RGBColor[255/255 , 153/255 , 0/255];
color37 = RGBColor[255/255 , 127.50/255 , 0/255];
color38 = RGBColor[255/255 , 102/255 , 0/255];
color39 = RGBColor[255/255 , 76.50/255 , 0/255];
color40 = RGBColor[255/255 , 51/255 , 0/255];
color41 = RGBColor[255/255 , 25.50/255 , 0/255];
color42 = RGBColor[255/255 , 0/255 , 0/255];
color43 = RGBColor[255/255 , 51/255 , 51/255];
color44 = RGBColor[255/255 , 102/255 , 102/255];
color45 = RGBColor[255/255 , 153/255 , 153/255];
color46 = RGBColor[255/255 , 204/255 , 204/255];
color47 = RGBColor[255/255 , 255/255 , 255/255];
Each colour represents a temperature degree as below:
color1 -> -22
color2 -> -21.125
color3 -> -20.25
color4 -> -19.375
color5 -> -18.5
color6 -> -17.625
color7 -> -16.75
color8 -> -15.875
color9 -> -15
color10 -> -14
color11 -> -13
color12 -> -12
color13 -> -11
color14 -> -10
color15 -> -9
color16 -> -8
color17 -> -7
color18 -> -6
color19 -> -5
color20 -> -4
color21 -> -3
color22 -> -2
color23 -> -1.6
color24 -> -1.2
color25 -> -0.8
color26 -> -0.4
color27 -> 0
color28 -> 0.4
color29 -> 0.8
color30 -> 1.2
color31 -> 1.6
color32 -> 2
color33 -> 3.6
color34 -> 5.2
color35 -> 6.8
color36 -> 8.4
color37 -> 10
color38 -> 13
color39 -> 16
color40 -> 19
color41 -> 22
color42 -> 25
color43 -> 28
colo44 -> 31
color45 -> 34
color46 -> 37
color47 -> 40
What I would like to do now is to create just the bar legend of these colours with the desired distributions. As you can see my colour function is nonlinear and the colours are not equally spaced along the temperature range. However, when I use the following code, I realise that mathematica just linearly distribute the colours and does not take into consideration the temperatures that I have specified.
BarLegend[{{color1 , color2 , color3 , color4 , color5 , color6 ,
color7 , color8 , color9 , color10 , color11 , color12 , color13 ,
color14 , color15 , color16 , color17 , color18 , color19 ,
color20 , color21 , color22 , color23 , color24 , color25 ,
color26 , color26 , color27 , color28 , color29 , color30 ,
color31 , color32 , color33 , color34 , color35 , color36 ,
color37 , color38 , color39 , color40 , color41 , color42 ,
color43 , color44 , color45 , color46 , color47} , {-22 ,
40}} , {-22 , -21.125 , -20.25, -19.375 , -18.5 , -17.625 , -16.75
, -15.875 , -15 , -14 , -13 , -12 , -11 , -10 , -9 , -8 , -7 , -6 ,
-5 , -4 , -3 , -2 , -1.6 , -1.2 , -0.8 , -0.4 , 0 , 0.4 , 0.8 , 1.2 ,
1.6 , 2 , 3.6 , 5.2 , 6.8 , 8.4 , 10 , 13 , 16 , 19 , 22 , 25 ,
28 , 31 , 34 , 37 , 40}, LegendLayout -> "Row" ,
LabelStyle -> {Black }]
Is there any solution for creating this barlegend?
thanks in advance