I am plotting the graph of the logistic equation in a manipulate. My borders range from {x, 0, 100}, {y, 0, 100}. I would like to fill the background of the plot with a light grey color, almost completely transparent, over a range from {x, 0, 20}, {Y, 0, 100}. How might I go about doing this?
1 Answer
If you just want to fill the background of the plot and don't need to fill under the curve, I would use Prolog
and Rectangle
.
Plot[
x,
{x, 0, 100},
PlotRange -> {{0, 100}, {0, 100}},
Prolog -> {
GrayLevel[0.95],
Rectangle[{0, 0}, {20, 100}]
}
]
-
$\begingroup$ Sounds like what I'm looking for. Where do I locate the code in a manipulate? $\endgroup$– HenryBMar 23, 2020 at 20:06
-
$\begingroup$ Without knowing how you're plotting your equation, it's difficult to say. If you're using
Plot
,ListPlot
,ParametricPlot
, or some other version, you can do it the way I show. If you're using aGraphics
environment, then you can simply include theGrayLevel
andRectangle
commands in the list of graphics to create. If you include either a minimal working example, or at least more details, it'll be easier for you to get help. $\endgroup$ Mar 23, 2020 at 22:25 -
$\begingroup$ I was able to get your code working in a Plot. Unfortunately, when I tried to combine the Plot with other data sets using the function 'Show' your shaded area disappeared. $\endgroup$– HenryBMar 24, 2020 at 14:22
-
$\begingroup$ If you're using
Show
, any options should either go into the first thing that you're showing, or else go as options toShow
itself.Show
only looks at the first thing and takes its options, unless its given options directly. SoShow[Plot[x, {x, 0, 100}, Prolog->{stuff}], Plot[otherfunction...]]
should work, or you can doShow[Plot[x, {x, 0, 100}], Plot[...], Prolog->{GrayLevel[0.99], Rectangle[...]}]
. $\endgroup$ Mar 24, 2020 at 18:33 -
$\begingroup$ Thanks for your help. Everything's working, but I have one more request. How do I change the color of the background rectangle to say, light blue? $\endgroup$– HenryBMar 25, 2020 at 18:41