3
$\begingroup$

I would like to draw a ListContourPlot in Log Log scale as well as bar legend. But I have no idea about how to do it. Could anyone help me to draw the plot in Log Log scale?

ListContourPlot[ConfVar, InterpolationOrder -> 2, PlotLegends -> 
BarLegend[Automatic, LegendLabel -> "sin \!\(\*SubscriptBox[\(\[Theta]\), \(12\)]\)"], 
ContourStyle -> None, Frame -> True]

And the result is a below plot.

enter image description here

Functions and coefficients for this plot are

\[Alpha]em = 1/137

mmu = 102.8/1000

F[x_] := (5*x^4 - 14*x^3 + 39*x^2 - 38*x - 18*x^2*Log[x] + 8)/(12*(1 - x)^4)

\[CapitalGamma]totalmu = 3*10^-19

Brmutoe\[Gamma]expmax = 4.2*10^-13

Brmutoe\[Gamma][MZprime_, s24squad_, s12_] := \[Alpha]em/(1024*Pi^4)*
mmu^5/(MZprime^4*\[CapitalGamma]totalmu)*s24squad^4*s12^2*
F[(mmu/MZprime)^2]^2*(1 + (1 - s24squad)/s24squad*F[(1001/MZprime)^2]/F[(mmu/MZprime)^2])

imax = 10^5

ConfVar = {};
For[i = 1, i <= imax, i++,
MZprimer = RandomReal[{100, 1000}];
s24squadr = RandomReal[{0, 1}];
s12r = RandomReal[{10^-5, 10^-1}];
Brmutoe\[Gamma]r = Brmutoe\[Gamma][MZprimer, s24squadr, s12r];
valf1 = MZprimer;
valf2 = s24squadr;
valf3 = s12r;
valf4 = Brmutoe\[Gamma][MZprimer, s24squadr, s12r]; 
If[valf4 < Brmutoe\[Gamma]expmax, {ConfVar = 
Join[ConfVar, {{valf1, valf2, valf3}}]}]]

Many thanks for someone's help in advance.

$\endgroup$
10
  • $\begingroup$ Look at the ScalingFunctions option. For example ScalingFunctions -> "Log10" $\endgroup$ Feb 8, 2019 at 18:36
  • $\begingroup$ @DavidKeith Thanks for your suggestion, but when I tried that method, the y-axis of this plot is from 10^-5 to 1. But I need the y-axis to be from 10^-3 to 1. How can I fix that problem? $\endgroup$
    – lhcQFT
    Feb 8, 2019 at 18:46
  • $\begingroup$ @lhcQFT by using the PlotRange->{{xmin,xmax},{ymin,ymax},{zmin,zmax}} option... $\endgroup$
    – a20
    Feb 8, 2019 at 19:02
  • $\begingroup$ @lhcQFT Parameter is not defined ` [CapitalGamma]totalmu` $\endgroup$ Feb 8, 2019 at 19:03
  • $\begingroup$ @bjorn Thanks, I will try it. $\endgroup$
    – lhcQFT
    Feb 8, 2019 at 19:10

2 Answers 2

4
$\begingroup$

I have not been able to generate data from your code, but here is an example with fake data:

lst = Flatten[
   Table[{x, y, 1 + (Sin[x] + 10) Exp[-(x - 2)^2 - (y - 3)^2]},
    {x, 2, 4, .1}, {y, 2, 4, .1}],
   1];

ListContourPlot[lst, PlotLegends -> Automatic]

enter image description here

ListContourPlot[lst, PlotLegends -> Automatic, 
 ScalingFunctions -> {"Log10", "Log10", "Log10"}]

enter image description here

$\endgroup$
2
  • $\begingroup$ @DaividKeith Thank you for your example. I forgot to write down one important information in my text and edited it. But is there a better way to express bar legend like 10^-n rather than arbitrary number? $\endgroup$
    – lhcQFT
    Feb 8, 2019 at 19:30
  • $\begingroup$ @ihcQFT Sorry, I do not know a way to do this. There might well be a way, but I find the behavior of ListContourPlot quite strange when trying to specify contours with a Log scale. Perhaps someone else will point the way. $\endgroup$ Feb 8, 2019 at 20:36
3
$\begingroup$

If you have the right dynamic range in the data, it will scale appropriately. Otherwise, you can put your own numbers into the PlotLegends field.

PlotLegends -> BarLegend[10^-Range[5]

You can specify the frame ticks (numbers along the axes) with FrameTicks[]. For example, if the default output was not to our liking, we could have achieved the same result with

FrameTicks -> {{10^Range[2], None}, {10.0^Range[2], None}}]

As mentioned in the comments, use PlotRange[] to specify the range of values.

Putting it all together ...

ListContourPlot[ConfVar, InterpolationOrder -> 2, 
  PlotLegends -> BarLegend[10^-Range[5], 
    LegendLabel -> "sin \(\*SubscriptBox[\(\[Theta]\), \(12\)]\)"], 
    ContourStyle -> None, Frame -> True, 
    ScalingFunctions -> {"Log10", "Log10", "Log10"}, 
    FrameTicks -> {{10^Range[-3, 0], None}, {10.0^Range[3], None}},
    PlotRange -> {Automatic, {10^-3, 1}, Automatic}]

Resulting image

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.