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 1


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.

  {x, 0, 100},
  PlotRange -> {{0, 100}, {0, 100}},
  Prolog -> {
    Rectangle[{0, 0}, {20, 100}]

enter image description here

  • $\begingroup$ Sounds like what I'm looking for. Where do I locate the code in a manipulate? $\endgroup$
    – HenryB
    Mar 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 a Graphics environment, then you can simply include the GrayLevel and Rectangle 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$
    – MassDefect
    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$
    – HenryB
    Mar 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 to Show itself. Show only looks at the first thing and takes its options, unless its given options directly. So Show[Plot[x, {x, 0, 100}, Prolog->{stuff}], Plot[otherfunction...]] should work, or you can do Show[Plot[x, {x, 0, 100}], Plot[...], Prolog->{GrayLevel[0.99], Rectangle[...]}]. $\endgroup$
    – MassDefect
    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$
    – HenryB
    Mar 25, 2020 at 18:41

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.