0
$\begingroup$

I have the following plot:

dat = {{255, 255, 255}, {0, 0, 153}, {0, 0, 0}, {204, 0, 0}, {255, 255, 255}};
With[{rgb = RGBColor @@@ (dat/255)}, cf = Blend[rgb, #] &;]
DensityPlot[E^(-2 p0^2 - x0^2/2)/π, {x0, -10, 10}, {p0, -7, 7}, 
ColorFunction -> cf, PlotLegends -> Automatic, WorkingPrecision -> 1000, 
PlotPoints -> 100, MaxRecursion -> 5, PlotRange -> {Full, Full, {-1, 1}}]

I try to fix the Plot Range from -1 to 1, but they only allow me to fix it between the maximum and the minimum value of the function, the problem is that i want to compare different plots from different calculations, I am interested just to fix the plotrange to a given one, independently of the function in the plot. I thought it would be simple, but i cannot manage to do it.

$\endgroup$
  • $\begingroup$ the option of rescale is not posible, for what i comment about the later comparison with other results. $\endgroup$ – Mento May 11 '15 at 16:42
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey May 11 '15 at 16:54
  • $\begingroup$ Try and take a look at the discussion in question (82947). $\endgroup$ – MarcoB May 11 '15 at 17:08
  • $\begingroup$ Specifically, try adding ColorFunctionScaling -> False. $\endgroup$ – bbgodfrey May 11 '15 at 17:11
1
$\begingroup$

In order to establish the range of the PlotLegends bar to a given interval, we can add the following option to the DensityPlot

PlotLegends -> Placed[BarLegend[{Automatic, {-1, 1}}], Right]

enter image description here

Additionaly, we can adjust the x and y axes in the PlotRange option to produce a better result.

$\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.