# Fixed colors for fixed values in contourplot legend

I am trying to make a contour plot of a gravitational potential, consisting of a sum og different potential.s.

I would like to plot them separately with a BarLegend that has the same colors for the same values of the potential. What I got now is that the colors in the two plots does not represent the same potential energy. Here's an example:

contplotb =
ContourPlot[1/Sqrt[R^2 + z^2 + 1], {R, 0, 10}, {z, -10, 10},
PlotRange -> All,
PlotLegends -> BarLegend[Automatic, All, LegendFunction -> "Panel"]]

contplotd =
ContourPlot[3/Sqrt[R^2 + z^2 + 1], {R, 0, 10}, {z, -10, 10},
PlotRange -> All,
PlotLegends -> BarLegend[Automatic, All, LegendFunction -> "Panel"]]


As you may see, the colors represent different values, but it would be nice to have them represent the same

Any tips are much apreciated, and please include code if you have a solution, I'm very new to Mathematica.

Thanks Espen

• closely related Q/As: Scale coloring of ContourPlot and Set the same color scale across multiple ListContourPlots
– kglr
Commented Apr 13, 2015 at 19:03
• Use ColorFunction -> ColorData[{"Rainbow", {0, 3}}], ColorFunctionScaling -> False on both plots Commented Apr 13, 2015 at 19:44
• Thank you, guys! I checked out those other posts, but they seemed a bit more advanced than what I was after. Belisarius' answer worked just as I was hoping for. Commented Apr 14, 2015 at 6:46
• @belisarius Answer, or Close? Commented May 23, 2015 at 13:41

ColorFunction -> ColorData[{"Rainbow", {0, 3}}], ColorFunctionScaling -> False