2
$\begingroup$

How to fill colors between GridLines, or to color between different regions on the x-axis, like this graph. Also to add the descriptions inside the plot, and to make the AxesLabels beside and below the plot as ln H and ln (a/a0), respectively. enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

Here is an example using several Plot options. Not sure if this will be enough--maybe you need dynamic computation of some options, but hopefully this will get you started:

Plot[
  {Sin[x], Cos[x]}, {x, 0, 10},
  AxesOrigin -> {0, -1},
  Frame -> True, FrameTicks -> All,
  Prolog -> {LightBrown, Rectangle[{-1, -2}, {3, 2}], LightGreen, Rectangle[{8, -2}, {11, 2}]},
  FrameLabel -> {Log[a/Subscript[a, 0]], Log[H]},
  PlotLegends -> Placed["Expressions", {.6, .15}]]

enter image description here

$\endgroup$
3
  • 3
    $\begingroup$ I usually use a device similar to the one here for background rectangles, whenever I can't be bothered to reckon out vertical ranges: Plot[{Sin[x], Cos[x]}, {x, 0, 10}, AxesOrigin -> {0, -1}, Frame -> True, FrameTicks -> All, Prolog -> {{LightBrown, Rectangle[Scaled[{0, -1}, {0, 0}], Scaled[{0, 1}, {3, 0}]]}, {LightGreen, Rectangle[Scaled[{0, -1}, {8, 0}], Scaled[{0, 1}, {10, 0}]]}}, FrameLabel -> {Log["a"/Subscript["a", 0]], Log["H"]}, PlotLegends -> Placed["Expressions", {.6, .15}]] $\endgroup$ Commented Jun 8, 2022 at 17:30
  • 1
    $\begingroup$ Nice improvement! $\endgroup$
    – lericr
    Commented Jun 8, 2022 at 17:32
  • $\begingroup$ Many thanks for the answers. $\endgroup$
    – Dr. phy
    Commented Jun 8, 2022 at 17:55

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.