1
$\begingroup$

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