1
$\begingroup$

I'm using SmoothDensityPlot to compare two data sets DATA1 and DATA2, in which, each one has its respective maximum value, so I would like to set a BarLegend (already discussed here) corresponding to maximum value in DATA1 (around 20) and see the corresponding brighter spot in DATA2 (around 0.07) less bright.

More than that, only setting this on barlegend does not affects the density intensity plot, so I need to set this max value in SmoothDensityPlot to see something like this, I think..(Photoshop edit)

enter image description here Made using

Legended[SmoothDensityHistogram[wd, .025, PlotPoints -> 50, 
  MaxRecursion -> 4, ColorFunction -> "SolarColors", 
  PlotRange -> {{-1.3, 0.8}, {0.6, 2.2}}, AspectRatio -> 0.8, 
  Frame -> False, ImageSize -> 600], 
 BarLegend[{"SolarColors", {0, 20}}]]

where wd is

wd = WeightedData[SetAccuracy[DATA1[[All, ;; 2]],2], DATA1[[All, -1]]];

How could I do that?

$\endgroup$

1 Answer 1

0
$\begingroup$

The color corresponding to the lowest value in the "SolarColors" scheme isn't black but more of a red, so you're gonna need to look for another color scheme to plot something similar to your photoshopped image. To use customized color scaling & function, you could try the following options:

ColorFunctionScaling -> False
ColorFunction -> (ColorData["SunsetColors"][#/cm] &)

where cm = Max@Join[DATA1[[All, 3]], DATA2[[All, 3]]] so that #/cm ranges 0~1 for both of the data sets:

plot = SmoothDensityHistogram[
    #, .025, PlotRange -> {{-1.3, 0.8}, {0.6, 2.2}}
    , AspectRatio -> 0.8, Frame -> False, ImageSize -> 600
    , PlotPoints -> 50, MaxRecursion -> 4
    , ColorFunctionScaling -> False
    , ColorFunction -> (ColorData["SunsetColors"][#/cm] &)
] & /@ {wd, wd2};
Row[plot]

enter image description here

You could also consider defining the color function using Blend.

$\endgroup$
2
  • $\begingroup$ The suggestion to do #/cm is nice! How could I do that with Blend? I wish I could get Black for 0 values, and Yellow for 1 contributions, and something between with Red. With your suggestion I get something between black, purple and white. Something like Blend[{Black,Red,Yellow} (Something related with the poits DATA[[All,3]] here #) ]/[#/cm], that I could not find to work $\endgroup$ Mar 4, 2022 at 18:46
  • $\begingroup$ I've tring to use ColorFunction->(Blend[{Black, Red, Orange}, #/cm] &) and works quite well! And have used BarLegend[{(Blend[{Black, Red, Orange}, #] &), {0, 1}}] without #/cm, works pretty well too, thank you for your help! $\endgroup$ Mar 4, 2022 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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