0
$\begingroup$

enter image description here

Write the code to display the exact image shown above.

$\endgroup$
  • $\begingroup$ Sounds like a give-me-the-codez question. And like homework. $\endgroup$ – Henrik Schumacher Feb 23 at 7:40
3
$\begingroup$

I would do it this way.

Show[
  Plot[{1/x}, {x, 0, 26},
    PlotRange -> {Automatic, {0, .6}}, 
    PlotStyle -> AbsoluteThickness[3]],
  Plot[{1/x}, {x, 2, 6},
    PlotRange -> {Automatic, {0, .6}},
    PlotStyle -> Transparent,
    Filling -> Axis,
    FillingStyle -> Red],
  Plot[1/x, {x, 8, 24},
    PlotRange -> {Automatic, {0, .6}},
    PlotStyle -> Transparent,
    Filling -> Axis,
    FillingStyle -> Blue],
  Ticks -> {{2, 6, 8, 24}, Automatic}]

plot

| improve this answer | |
$\endgroup$
0
$\begingroup$

A simple answer:

Show[Plot[{1/x, If[2 <= x <= 6, 0, 1/x]}, {x, 0, 26}, 
  Filling -> {1 -> {2}}, AxesOrigin -> {0, 0}, FillingStyle -> {Red}, 
  PlotRange -> {0, 0.6}, PlotStyle -> Black], 
 Plot[{1/x, If[8 <= x <= 24, 0, 1/x]}, {x, 0, 26}, 
  Filling -> {1 -> {2}}, AxesOrigin -> {0, 0}, FillingStyle -> {Blue},
   PlotStyle -> Black], Ticks -> {{2, 6, 8, 24}, Automatic}]
| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ I don't think this produces the exact image requested. $\endgroup$ – m_goldberg Feb 23 at 3:31
  • 1
    $\begingroup$ Thanks, It actually works, goldbergs code for some reason does not display. $\endgroup$ – vicsonsam Feb 23 at 6:28
  • 1
    $\begingroup$ @vicsonsam, code by m_goldberg works fine, I edited small typo in there, $\endgroup$ – Alx Feb 23 at 11:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.