1
$\begingroup$

I saw this image thus I guess that it is possible to color some regions in a plot. What kind of command can I use to have a similar plot?

enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ Please provide Mathematica code that would generate this plot and look up the Filling command. There are plenty of posts on this site that discuss it. $\endgroup$
    – Syed
    May 8, 2023 at 10:36
  • $\begingroup$ Thanks for your reply but I do not have the code. If you know a similar post please share it. $\endgroup$
    – Spook82
    May 13, 2023 at 18:33

1 Answer 1

5
$\begingroup$

The option Filling can color the space between plotted lines (see documentation). In your case, where lines do not intersect, it is easier to stack the plots inside a Show command and fill all the way to the bottom axis and stack the plots in such order that the filling color of the next plot is on top of the last one:

Show[
 Plot[2 Sqrt[x] + x, {x, 0, 200}, Frame -> True, Filling -> Top, 
  FillingStyle -> RGBColor[0.92, 0.9, 0.], PlotRange -> {0, 200}, 
  LabelStyle -> 14],
 Plot[1.05 (x - 10) + 10, {x, 40, 200}, Filling -> Axis, 
  PlotRange -> {0, 200}],
 Plot[0.7 (x - 10) + 20
  , {x, 40, 200}, Filling -> Axis, FillingStyle -> White, 
  PlotRange -> {0, 200} ],
 Plot[2 Sqrt[x - 10] + 0.5 (x - 10), {x, 10, 200}, Frame -> True, 
  PlotRange -> {0, 200}, LabelStyle -> 14]
 ]

which produces

enter image description here

Keep adding lines from top to bottom, so the Filling color of each new line goes on top of the previous line.

$\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.