1
$\begingroup$

This question already has an answer here:

What is an easy way to define a filling and a color for a curve in the subdomain going from $0$ to $1$?

Plot[x^-x, {x, 0, 4}, 
  AspectRatio -> 1/GoldenRatio, 
  Filling -> Axis, 
  FillingStyle -> Yellow]

enter image description here

I did it with Show, but is there exist easy way to use Filling or FillingStyle to do this in one plot?

Show[
  Plot[x^-x, {x, 0, 4}, AspectRatio -> 1/GoldenRatio],
  Plot[x^-x, {x, 0, 1}, 
    Filling -> Axis, 
    FillingStyle -> Yellow, 
    AspectRatio -> 1/GoldenRatio, 
    PlotRange -> {{0, 4}, {0, 1.5}}, 
    PlotStyle -> Red]]

enter image description here

$\endgroup$

marked as duplicate by MarcoB, Kuba, corey979, Feyre, Young Feb 8 '17 at 3:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1
$\begingroup$

Perhaps this will work for you.

Plot[{(x^-x) Boole[x <= 1], (x^-x) Boole[x > 1]}, {x, 0, 4},
  Filling -> 1 -> Axis,
  PlotStyle -> {Red, Black},
  FillingStyle -> Yellow,
  PlotRange -> {Automatic, {.001, Automatic}}]

plot

$\endgroup$

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