0
$\begingroup$

I have four different lists that show different temperature changes in a wire. The minimum and maximum values of the lists are as follows (since there are 1000 elements in each list, I preferred just to insert the maximums and minimums):

min1 = -2; max1 = 2;
min2 = -10; max2 = 10;
min3 = -20; max3 = 20;
min4 = -40; max4 = 30;

Now, I would like to use ListDensityPlot to plot the temperatures along the wire. My question is very general. How can I set the ColorFunction in such a way that the color legend for all the four plots will be the same but I will be also able to see the temperature change for the first plot (with min1 = -2 , max1 = 2). I tried to use "TemperatureMap" but I couldn't control the range. Is there any suggestion?

The lists are as follows:

S1 = {{0, 0, 0}, {0.01025, 391/40, 0.252497}, {0.01625, 783/40, 
  0.679141}, {0.02225, 235/8, 0.111459}, {0.029, 183/20, 
  1.62408}, {0.035, 379/20, 2.08228}, {0.041, 115/4, 
  0.234905}, {0.04775, 341/40, 0.375804}, {0.058, 733/40, 
  0.00116476}, {0.064, 225/8, -0.28142}, {0.07075, 79/
  10, -0.719961}, {0.07675, 177/10, -1.09275}, {0.08275, 55/
  2, -0.4097}, {0.0895, 291/40, -1.21021}, {0.0955, 683/
  40, -2.18459}, {0.1, 30, 0.}};

S2 = {{0, 0, 0}, {0.01025, 391/40, 0.323326}, {0.01625, 783/40, 
  1.77028}, {0.02225, 235/8, 0.697066}, {0.029, 183/20, 
  9.29734}, {0.035, 379/20, 12.8282}, {0.041, 115/4, 
  1.59031}, {0.04775, 341/40, 12.3881}, {0.058, 733/40, 
  8.00715}, {0.064, 225/8, 0.58125}, {0.07075, 79/
  10, -3.5893}, {0.07675, 177/10, -3.88711}, {0.08275, 55/
  2, -2.08424}, {0.0895, 291/40, -7.60716}, {0.0955, 683/
  40, -10.0477}, {0.1, 30, 0.}};

S3 = {{0, 0, 0}, {0.01025, 391/40, 1.3907}, {0.01625, 783/40, 
  6.65005}, {0.02225, 235/8, 2.79659}, {0.029, 183/20, 
  14.9936}, {0.035, 379/20, 19.4062}, {0.041, 115/4, 
  5.48806}, {0.04775, 341/40, 31.2655}, {0.058, 733/40, 
  27.7984}, {0.064, 225/8, 7.13376}, {0.07075, 79/10, 
  10.9521}, {0.07675, 177/10, 5.07357}, {0.08275, 55/2, 
  1.40042}, {0.0895, 291/40, -3.24734}, {0.0955, 683/40, 
  1.72303}, {0.1, 30, 0.}};

S4 = {{0, 0, 0}, {0.01025, 391/40, 2.90893}, {0.01625, 783/40, 
  7.22693}, {0.02225, 235/8, 8.96227}, {0.029, 183/20, 
  16.8355}, {0.035, 379/20, 21.9125}, {0.041, 115/4, 
  18.6437}, {0.04775, 341/40, 33.9003}, {0.058, 733/40, 
  30.6217}, {0.064, 225/8, 20.3588}, {0.07075, 79/10, 
  19.0083}, {0.07675, 177/10, 13.4778}, {0.08275, 55/2, 
  12.8769}, {0.0895, 291/40, 3.17187}, {0.0955, 683/40, 
  2.93293}, {0.1, 30, 0.}};
$\endgroup$
3
  • $\begingroup$ Have you played around with ColorFunctionScaling? Could you post your code (perhaps with simulated data), so that people can see how it's not working? $\endgroup$ – aardvark2012 Jun 29 '17 at 8:56
  • $\begingroup$ The lists are too large. Its not possible to copy past them here. $\endgroup$ – KratosMath Jun 29 '17 at 9:00
  • $\begingroup$ I inserted abstracts of the data. $\endgroup$ – KratosMath Jun 29 '17 at 9:17
1
$\begingroup$

Maybe

Legended[Grid[Partition[
              ListDensityPlot[#, 
              ColorFunction -> ColorData[{"TemperatureMap", {-40, 30}}], 
              ColorFunctionScaling -> False] & /@ {S1, S2, S3, S4},
              2]], 
   BarLegend[{ColorData[{"Temperature", {-40, 30}}], {-40, 30}}]]

Mathematica graphics

$\endgroup$
5
  • $\begingroup$ Thanks for your solution. But is it possible to increase the sensitivity of the colours so that even for the first one we would be able to see the temperature change? One possible solution could be defining many colours for the colorfunction. But I don't know how to do it. $\endgroup$ – KratosMath Jun 29 '17 at 10:08
  • $\begingroup$ @M.Rock, i am not sure how that can be done. Some scaling of your data may work but i don't know how. $\endgroup$ – kglr Jun 29 '17 at 10:22
  • $\begingroup$ thanks for your answer by the way. $\endgroup$ – KratosMath Jun 29 '17 at 10:25
  • $\begingroup$ @M.Rock, my pleasure. Welcome to mma.se. $\endgroup$ – kglr Jun 29 '17 at 10:26
  • $\begingroup$ @M.Rock. You are over-constraining the problem when you insist on one legend for all the plots as well as being able to discriminate over small temperature changes. Especially, when the temperature range in specify for the legend greatly exceeds the temperature range of your data. You will get somewhat better discrimination by specify temperature range to be {-4, 30} $\endgroup$ – m_goldberg Jun 29 '17 at 17:30
0
$\begingroup$

I solved it. In order to have the same colour legend for all plots so that you can easily compare the results, a new colour function should be defined. By using RGBcolor function I created my own function and then inserted it in the listdensityplot.

mycolorTemp = 
 Blend[{{-30 , color1} , {-28.75 , color2} , {-27.5 , 
    color3} , {-26.25 , color4} , {-25 , color5} , {-23.75 , 
    color6} , {-22.5 , color7} , {-21.25, color8} , {-20 , 
    color9} , {-19 , color10} , {-18 , color11} , {-17 , 
    color12} , {-16 , color13} , {-15 , color14} , {-13.375 , 
    color15} , {-11.75 , color16} , {-10.125 , color17} , {-8.5 , 
    color18} , {-6.875 , color19} , {-5.25 , color20} , {-3.625 , 
    color21} , {-2 , color22} , {-1.6 , color23} , {-1.2 , 
    color24} , {-0.8 , color25} , {-0.4 , color26} , {0 , 
    color27} , {0.4 , color28} , {0.8 , color29} , {1.2 , 
    color30} , {1.6 , color31} , {2 , color32} , {3.6 , 
    color33} , {5.2 , color34} , {6.8 , color35} , {8.4 , 
    color36} , {10 , color37} , {15 , color38} , {20, 
    color39} , {25 , color40} , {30, color41} , {35 , color42} , {37, 
    color43} , {39 , color44} , {41 , color45} , {43 , 
    color46} , {45 , color47}} , #1]

where colorn is defined as,

colorn = RGBColor[x1 , x2 , x3].

The intensity of x1, x2 and x3 could be easily obtained according to the colour that you want. The following link is also helpful in creating the colour function.

https://codepen.io/leemark/pen/lpEHr

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.