I make a set of 6 DensityPlots with PlotLegends and different sets of params:

DensityPlot[(a^3/h^2)^-1 fun[x, y, {a, h, V}, g] /. params
 , {x, xmin, xmax} /. params // Evaluate
 , {y, ymin, ymax} /. params // Evaluate
 , Frame -> True, FrameLabel -> framelbl /. params // Evaluate
 , AspectRatio -> Automatic
 , PlotRange -> All
 , ColorFunction -> "Rainbow"
 , PlotLegends -> BarLegend[Automatic
   , LabelStyle -> {FontSize -> 16, Black}
   , LegendLabel -> "\[Zeta]\!\(\*SuperscriptBox[
StyleBox[\"h\",\nFontSlant->\"Italic\"], \(2\)]\)/\!\(\*SuperscriptBox[
StyleBox[\"a\",\nFontSlant->\"Italic\"], \(3\)]\)"
   , LegendMarkerSize -> 180]
 , MaxRecursion -> maxrecursions /. params // Evaluate
 , PlotPoints -> plotpoints /. params // Evaluate
 , BaseStyle -> {16}
 , ImageSize -> Medium
 , Epilog -> {White, Disk[{0.9, 0.9} // Scaled, 0.05 // Scaled]
   , Black, Text[lbl, {0.9, 0.9} // Scaled] /. params // Evaluate

Unfortunately, coloring of the plots turn out to be quite different because maximal and minimal values of function fun varies from plot to plot. Even zero level of fun has different color in different plots as shown below: enter image description here

I guess that zero level could get same color in all pictures if ColorFunction will be scaled assuming that maximal an minimal values of fun are the same by absolute value and differs by their sign only. How to do that?

Update: Although there are several similar posts at this forum, which allows to solve my problem by preliminary computation of minimal and maximal values of plotted function I would be totally satisfied if such a computation could be automated. I mean that DensityPlot internally for sure computes these values as it by defaults scales color data to the range {0,1}. Is it possible to retrieve these internal values and feed them to ColorFunction[...,{-1,1}*Max@Abs[{InternalMin, InternalMax}]], where InternalMin and InternalMax are these internally computed values?

  • 1
    $\begingroup$ You have to find the minimum and maximum value of the set of six plots. Using this information, and an appropriate ColorFunction which could use Rescale together with a setting of ColorFunctionScaling -> False would do what you want. $\endgroup$ Mar 3, 2016 at 7:34
  • $\begingroup$ Would you like every image to be using exactly the same color scale? Or just that every image has the same color at 0? Also you should consider whether you really want a Rainbow color map. Your data should really use a divergent isoluminal colormap, have a google about why rainbow is so bad! $\endgroup$ Mar 3, 2016 at 9:17
  • $\begingroup$ You may find information relevant to your problem in this answer $\endgroup$
    – m_goldberg
    Mar 3, 2016 at 9:21
  • $\begingroup$ @Quantum_Oli: Preferebly, I want to have different scales for different plots as I am afraid that with common scale figure a will look almost monochrome. $\endgroup$ Mar 3, 2016 at 10:06
  • $\begingroup$ related q/a: Set the same color scale across multiple ListContourPlots? $\endgroup$
    – kglr
    Mar 3, 2016 at 17:35


Browse other questions tagged or ask your own question.