3
$\begingroup$

I have the following contour plot

Mpl = 1.22*10^(19)
Tplot = ContourPlot[Log10[0.5 1/(100)^(1/8) Sqrt[Mpl 10^x] (y)^(6/8)Exp[-(y)^3 1/8]], 
{x, -6, 16}, {y, 1, 10}, PlotLegends -> Automatic, FrameLabel -> {"x", "y"}]

enter image description here

I would like to shade the regions of contours corresponding to values (for simplicity) > 10 and < -10. (The idea is that those regions are not allowed). I feel like there should be an easy way of doing this. The idea is as below enter image description here

$\endgroup$
4
$\begingroup$

Mathematica 12.1 has HatchFilling :

Mpl = 1.22*10^(19)
ContourPlot[
 Log10[0.5 1/(100)^(1/8) Sqrt[
    Mpl 10^x] (y)^(6/8) Exp[-(y)^3 1/8]], {x, -6, 16}, {y, 1, 10}
 , PlotLegends -> Automatic
 , FrameLabel -> {"x", "y"}
 , ClippingStyle -> {HatchFilling[]}
 , PlotRange -> {Automatic, Automatic, {-10, 10}}]  

enter image description here

It can be superposed with the original plot :

 Mpl = 1.22*10^(19)
 Show[ContourPlot[
  Log10[0.5 1/(100)^(1/8) Sqrt[
     Mpl 10^x] (y)^(6/8) Exp[-(y)^3 1/8]], {x, -6, 16}, {y, 1, 10}, 
  FrameLabel -> {"x", "y"}, PlotLegends -> Automatic], 
 ContourPlot[
  Log10[0.5 1/(100)^(1/8) Sqrt[
     Mpl 10^x] (y)^(6/8) Exp[-(y)^3 1/8]], {x, -6, 16}, {y, 1, 10}(*,
  PlotLegends\[Rule]Automatic*),(*FrameLabel\[Rule]{"x","y"},*)
  ClippingStyle -> {HatchFilling[]}, 
  PlotRange -> {Automatic, Automatic, {-10, 10}}, 
  RegionFunction -> Function[{x, y, z}, z < -10 || z > 10]]]

enter image description here

$\endgroup$
2
  • $\begingroup$ This is pretty good. The only thing is when you superimpose in this way the two sets of contour lines don't agree. See for example there are two dark blue strips $\endgroup$
    – Rudyard
    Mar 30 at 21:21
  • $\begingroup$ problem mentionned in comment just above ("superimpose... agree") corrected. $\endgroup$
    – andre314
    Mar 31 at 12:17

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.