3
$\begingroup$

I'm trying to plot two functions (X1 and X2) in a single plot as shown in the example

X1 = 1.3335698177171183`*^8 a^2 - 3.636178913116437`*^8 a b + 
  3.280532719877099`*^8 b^2  

X2 = 2.5163488578437388`*^8 Abs[a]^2

Panel[Show[
      ContourPlot[X1, {a, 0.014, 0.018}, {b, 0.003, 0.012}, 
       Contours -> 15, ContourShading -> None, ContourLabels -> {All, 50},
        BaseStyle -> {FontSize -> 18}], 
      ContourPlot[X2, {a, 0.008, 0.025}, {b, 0, 0.15}, Contours -> 48, 
       ContourShading -> None, ContourLabels -> All, 
       ContourStyle -> Dotted], 
      FrameLabel -> {Style[
         "\!\(\*SubsuperscriptBox[\(C\), \(\[Phi]l\), \
    \(23\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
         Bold], Style[
         "\!\(\*SubsuperscriptBox[\(C\), \(ll\), \
    \(23\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
         Bold]}, FrameTicksStyle -> Directive[FontSize -> 22]]]

and the output is here

My output

But I want to have something like this which is visually appealing and also easy to understand the allowed/discarded region on the plot.

Desired Output

Can anybody help me in getting this ? Thanks.

I've used the code provided by @MassDefect according to my need

leg = LineLegend[{Black, Dashed, Dashing[{0.02, 0.02, 0.008, 0.02}], 
    Dashing[{0.03, 
      0.03}]}, {"BR(Z\[Rule]\[Mu]\[Tau])=\!\(\*SuperscriptBox[\(10\), \
\(-13\)]\)", 
    "BR(Z\[Rule]\[Mu]\[Tau])=\!\(\*SuperscriptBox[\(10\), \(-11\)]\)",
     "BR(Z\[Rule]\[Mu]\[Tau])=\!\(\*SuperscriptBox[\(10\), \(-9\)]\)",
     "BR(Z\[Rule]\[Mu]\[Tau])=\!\(\*SuperscriptBox[\(10\), \
\(-7\)]\)"}, LabelStyle -> Directive[Bold, 8], 
   LegendFunction -> (Framed[#1, Background -> White, 
       FrameMargins -> 3, FrameStyle -> AbsoluteThickness[2], 
       RoundingRadius -> 2] &)];
Show[ContourPlot[X1, {a, 1*^-6, 0.1}, {b, 1*^-6, 0.1}, 
  Contours -> {5000}, 
  ContourShading -> {None, Lighter@Lighter@ColorData[97][1]}, 
  ContourStyle -> None, 
  FrameLabel -> {Style[
     "\!\(\*SubsuperscriptBox[\(C\), \(\[Phi]l\), \
\(13\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
     Bold], Style[
     "\!\(\*SubsuperscriptBox[\(C\), \(ll\), \
\(13\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
     Bold]}, FrameStyle -> Directive[Black, AbsoluteThickness[1]], 
  ImageSize -> 400, LabelStyle -> Directive[Bold, 14], 
  PlotPoints -> 100, PlotRange -> Full, PlotRangePadding -> None, 
  ScalingFunctions -> {"Log10", "Log10"}, 
  Epilog -> {Inset[leg, Scaled[{0.015, 0.975}], {-1, 1}]}], 
 ContourPlot[X1, {a, 1*^-6, 0.1}, {b, 1*^-6, 0.1}, 
  ContourShading -> None, 
  ContourStyle -> 
   Thread[Directive[
     AbsoluteThickness[1.5], {Black, Dashed, 
      Dashing[{0.02, 0.02, 0.008, 0.02}], Dashing[{0.03, 0.03}]}]], 
  ScalingFunctions -> {"Log10", "Log10"}], 
 RegionPlot[X1 > Br\[Tau]3\[Mu], {a, 1*^-6, 0.1}, {b, 1*^-6, 0.1}]]

with

Br\[Tau]3\[Mu] = 2.1*10^-8

and the result is My new plot 1

Tried this simple code

Show[ContourPlot[X1, {a, 1*^-6, 0.02}, {b, 1*^-6, 0.02}, 
  Contours -> {5*10^-2, 5, 5*10^2, 5*10^3}, ContourLabels -> True, 
  ContourShading -> {None, Lighter@Lighter@ColorData[97][1]}], 
 RegionPlot[X1 > Br\[Tau]3\[Mu], {a, 1*^-6, 0.1}, {b, 1*^-6, 0.1}]]

to incorporate the RegionPlot, but it doesn't seem to be compatible with ScalingFunction

$\endgroup$
4
  • 1
    $\begingroup$ @expikx No, this is not about the fontsize! I'm trying to get the idea of generating those nice panel plots. $\endgroup$ – Joy Apr 2 '20 at 11:53
  • 1
    $\begingroup$ Please be specific about which aspect of the second figure you want to reproduce. I don't understand what a "panel plot" is. Do you just want a legend? $\endgroup$ – Szabolcs Apr 2 '20 at 12:31
  • $\begingroup$ @Szabolcs, I want to reproduce exactly identical plot of the second figure, not any particular aspect. I think this kind of plot has something to do with 'panel' command, but I'm not sure! $\endgroup$ – Joy Apr 2 '20 at 14:17
  • 1
    $\begingroup$ Take a look at Epilog and Inset. Check the Applications section of the Inset documentation. $\endgroup$ – Rohit Namjoshi Apr 2 '20 at 16:39
7
$\begingroup$

I'm not sure if this is quite what you wanted, but I think I was able to get reasonably close to the style of the second picture. Hopefully this is close enough that you can make any changes you need to and have it correct. The main thing I didn't do, is I don't have X2 added because I wasn't quite sure how you wanted the contours selected, but you should be able to apply the styling I used below to your own plot.

leg = LineLegend[
   {Black, Dashed, Dashing[{0.02, 0.02, 0.008, 0.02}], Dashing[{0.03, 0.03}]},
   {"0.05", "5", "500", "50000"},
   LabelStyle -> Directive[Bold, 14],
   LegendFunction -> (Framed[#1,
     Background -> White, 
     FrameMargins -> 5, 
     FrameStyle -> AbsoluteThickness[2], 
     RoundingRadius -> 6] &)
 ];
Show[
  ContourPlot[
    X1,
    {a, 1*^-6, 0.1},
    {b, 1*^-6, 0.1},
    Contours -> {5000},
    ContourShading -> {None, Lighter@Lighter@ColorData[97][1]},
    ContourStyle -> None,
    FrameLabel -> {Style[
     "\!\(\*SubsuperscriptBox[\(C\), \(\[Phi]l\),     \
\(23\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
     Bold], Style[
     "\!\(\*SubsuperscriptBox[\(C\), \(ll\),     \
\(23\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
     Bold]},
    FrameStyle -> Directive[Black, AbsoluteThickness[1]],
    ImageSize -> 400,
    LabelStyle -> Directive[Bold, 14],
    PlotPoints -> 100,
    PlotRange -> Full,
    PlotRangePadding -> None,
    ScalingFunctions -> {"Log10", "Log10"},
    Epilog -> {
      Inset[leg, Scaled[{0.025, 0.975}], {-1, 1}]
    }
  ],
  ContourPlot[
    X1,
    {a, 1*^-6, 0.1},
    {b, 1*^-6, 0.1},
    Contours -> {0.05, 5, 500, 50000},
    ContourShading -> None,
    ContourStyle -> 
      Thread[
        Directive[
          AbsoluteThickness[1.5], 
          {Black, Dashed, Dashing[{0.02, 0.02, 0.008, 0.02}], Dashing[{0.03, 0.03}]}]],
    ScalingFunctions -> {"Log10", "Log10"}
  ]
]

Styled contour plot.

EDIT 01:

I've updated the code to include the intersections. I'm calculating and plotting the intersections at the very end of the code (where it has Table and NSolve). There are other ways to find these points such as MeshFunctions, but this seemed the most straightforward method to me. Note that while I've only plotted the intersections of the contours themselves, X1 and X2 intersect along a line that goes through the points I show. If you wanted to see that intersection, you could use ContourPlot[X1 == X2, ...].

leg = LineLegend[{Black, Dashed, Dashing[{0.02, 0.02, 0.008, 0.02}], 
    Dashing[{0.03, 0.03}]}, {"0.05", "5", "500", "50000"}, 
   LabelStyle -> Directive[Bold, 14], 
   LegendFunction -> (Framed[#1, Background -> White, 
       FrameMargins -> 5, FrameStyle -> AbsoluteThickness[2], 
       RoundingRadius -> 6] &)];
Show[
 ContourPlot[
  X1,
  {a, 1*^-6, 0.1},
  {b, 1*^-6, 0.1},
  Contours -> {5000},
  ContourShading -> {None, Lighter@Lighter@ColorData[97][1]}, 
  ContourStyle -> None, 
  FrameLabel -> {Style[
     "\!\(\*SubsuperscriptBox[\(C\), \(\[Phi]l\),     \
\(23\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
     Bold], Style[
     "\!\(\*SubsuperscriptBox[\(C\), \(ll\),     \
\(23\)]\)/\!\(\*SuperscriptBox[\(\[CapitalLambda]\), \(2\)]\)", 20, 
     Bold]}, FrameStyle -> Directive[Black, AbsoluteThickness[1]], 
  ImageSize -> 400,
  LabelStyle -> Directive[Bold, 14],
  PlotPoints -> 100,
  PlotRange -> Full,
  PlotRangePadding -> None,
  ScalingFunctions -> {"Log10", "Log10"}],
 ContourPlot[
  X1,
  {a, 1*^-6, 0.1},
  {b, 1*^-6, 0.1},
  Contours -> {0.05, 5, 500, 50000},
  ContourShading -> None, 
  ContourStyle -> 
   Thread[Directive[
     AbsoluteThickness[1.5], {Black, Dashed, 
      Dashing[{0.02, 0.02, 0.008, 0.02}], Dashing[{0.03, 0.03}]}]], 
  ScalingFunctions -> {"Log10", "Log10"}],
 ContourPlot[
  X2,
  {a, 1*^-6, 0.1},
  {b, 1*^-6, 0.1},
  Contours -> {0.05, 5, 500, 50000},
  ContourShading -> None,
  ContourStyle -> 
   Thread[Directive[AbsoluteThickness[1.5], 
     Blue, {Blue, Dashed, Dashing[{0.02, 0.02, 0.008, 0.02}], 
      Dashing[{0.03, 0.03}]}]],
  PlotPoints -> 100,
  ScalingFunctions -> {"Log10", "Log10"}
  ],
 Epilog -> {
   Inset[leg, Scaled[{0.025, 0.975}], {-1, 1}],
   Red,
   PointSize[Large],
   Point@Log10[
     Table[{a, b} /. 
       NSolve[{X1 == i, X2 == i, a > 0, b > 0}, {a, b}][[
        1]], {i, {0.05, 5, 500, 50000}}]]
   }
 ]

Updated styling contour plot to include intersection points.

$\endgroup$
8
  • $\begingroup$ Wow! Thanks a lot @MassDefect. I couldn't ask for a better answer. That is exactly what I wanted. $\endgroup$ – Joy Apr 3 '20 at 14:21
  • $\begingroup$ thanks again for your help. Regarding the equation X2, what I was trying to do was, to find the intersective contours for the functions X1 and X2. As you can see X1 gives parabolic contours whereas X2 gives straight line. Therefore I was trying to find the point where they both meet. Any idea ? $\endgroup$ – Joy Apr 7 '20 at 7:14
  • $\begingroup$ @Joy I'm not sure if it's styled in the way you'd like, but I've added X2 as well as its intersections. If you search this site for "find intersections", you can also find other ways of doing this. $\endgroup$ – MassDefect Apr 8 '20 at 19:11
  • $\begingroup$ thanks a lot again. Also, sorry for late reply as I was trying to customize your code according to my need. So, what I was trying are the following: $\endgroup$ – Joy Apr 11 '20 at 4:47
  • $\begingroup$ 1) Put a bound on X1(>Br[Tau]3[Mu]= 2.1*10^-8) through RegionPlot function, but was not sure where to put it! In the Ref. plot the shaded region is basically the excluded region 2) Also, in the Ref. plot, the contour seems to be free, satisfying X1, instead of fixed valued. Thus I modified the code, but don't seem to get desired value. $\endgroup$ – Joy Apr 11 '20 at 5:03

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.