5
$\begingroup$

I have a function firsttempinterp[x] that I plot using LogLogPlot. I used Filling to fill a region with gray color, however, using PlotRangePadding does not cover the entire region I want. The region is above the curve until the y-axis to the left. Any guide on how to resolve this?

temp = {0.1, 0.1355, 0.5, 10};
firsttime = {0.21707, 0.23616, 0.44440, 6.47129};
firsttempdata = Transpose[{firsttime, temp}];
firsttempinterp = 
  Interpolation[
    firsttempdata, 
    InterpolationOrder -> 2, 
    Method -> "Spline"
  ]

LogLogPlot[{
  If[x < 0.23616 + 3 2.361387, firsttempinterp[x - 3 2.361387] + 3 1.355, None],
  If[x > 0.23616 + 3 2.361387, firsttempinterp[x - 3 2.361387] + 3 1.355, None]},
  {x, 0, 17}, 
  Frame -> True,
  FrameStyle -> Directive[Black, 20],
  PlotStyle -> {{Dashed, Black, Thick}, {Black, Thick}},
  PlotRange -> {All, {0.09, 10.5}}, 
  PlotRangePadding -> 0, 
  Filling -> {
     1 -> {Top, {Directive[Opacity[0.3], Gray]}},
     2 -> {Top, {Directive[Opacity[0.3], Gray]}}
  },
  ImageSize -> Large
]

Image

$\endgroup$

3 Answers 3

4
$\begingroup$
LogLogPlot[Max[.09, firsttempinterp[x - 3 2.361387] + 3 1.355], {x, 0, 17}, 
 Frame -> True, FrameStyle -> Directive[Black, 20], 
 PlotStyle -> Directive[Thick, Black], 
 PlotRange -> {All, {0.09, 10.5}}, PlotRangePadding -> 0, 
 Filling -> Top,
 FillingStyle -> Directive[Opacity[0.3], Gray], 
 ImageSize -> Large, 
 MeshFunctions -> {#2 &}, 
 Mesh -> {{.09, 3 1.355}}, 
 MeshStyle -> None,
 MeshShading -> {None, Dashed, Dashing[{}]}, 
 PlotPoints -> 200, MaxRecursion -> 7]

enter image description here

$\endgroup$
6
$\begingroup$

With your definitions, add a gray background to the whole plot to represent your desired filling, then use an actual filling directive, using opaque white, to fill the part under the curve that should look "unfilled". The changes in your code are highlighted below between empty lines:

LogLogPlot[{
  If[x < 0.23616 + 3 2.361387, firsttempinterp[x - 3 2.361387] + 3 1.355, None],
  If[x > 0.23616 + 3 2.361387, firsttempinterp[x - 3 2.361387] + 3 1.355, None]},
  {x, 0, 17}, 
  Frame -> True,
  FrameStyle -> Directive[Black, 20],
  PlotStyle -> {{Dashed, Black, Thick}, {Black, Thick}},
  PlotRange -> {All, {0.09, 10.5}}, 
  PlotRangePadding -> 0, 

  Filling -> Axis, FillingStyle -> White,
  Prolog -> {
    Opacity[0.3, Gray],
    Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]
  },

  ImageSize -> Large
]

new plot with desired gray filling on left and top

$\endgroup$
3
$\begingroup$

Add a fake function:

Exp[x - 1.2] == 100

to your existing plot and adjust the constant as you see fit.

LogLogPlot[
 {If[x < 0.23616 + 3 2.361387,
   firsttempinterp[x - 3 2.361387] + 3 1.355, None],
  If[x > 0.23616 + 3 2.361387,
   firsttempinterp[x - 3 2.361387] + 3 1.355, None],
  Exp[x - 1.2] == 100
  }
 , {x, 0, 17}
 , Frame -> True
 , FrameStyle -> Directive[Black, 20]
 , PlotStyle -> {
   {Dashed, Black, Thick}
   , {Black, Thick}
   , {Dotted, Thin, Red}
   }
 , PlotRange -> {{0.1, 12}, {0.09, 10.5}}
 , PlotRangePadding -> 0
 , Filling -> {
   1 -> {Top, {Directive[Opacity[0.3], Gray]}}
   , 2 -> {Top, {Directive[Opacity[0.3], Blue]}}
   , 3 -> {Top, {Directive[Opacity[0.3], Pink]}}
   }
 , ImageSize -> Large,
 AspectRatio -> 0.75
 ]

I am showing the three colored regions, that you can revert to Gray.

enter image description here

$\endgroup$
3
  • $\begingroup$ One word, clever! Thanks! $\endgroup$
    – mathemania
    Commented Nov 18, 2021 at 8:24
  • $\begingroup$ Just last question, if I want to change firsttempinterp[x - 3 2.361387] + 3 1.355 to firsttempinterp[x - 2.361387] + 1.355, how should I control Exp[x - 1.2] == 100 so that there is no overlapping red/gray region? I'm trying to change 1.2 and 100 to some other values but the curve Exp[x - 1.2] == 100 overlaps a little bit on the top portion and has a gap on the bottom region. $\endgroup$
    – mathemania
    Commented Nov 18, 2021 at 9:02
  • $\begingroup$ If your requirements are changing, then I would advise you to accept the other answer and unaccept this one. It is a better solution. $\endgroup$
    – Syed
    Commented Nov 18, 2021 at 10:03

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.