# Filling a 2D plot with a texture

I am having trouble filling the bottom of the following plot:

Plot[Piecewise[{{Exp[-1/(1 - x^2)], Abs[x] < 1}, {0, Abs[x] >= 1}}], {x, -2, 2}] with the texture: I tried a few things, including:

im1 =
Plot[Piecewise[{{Exp[-1/(1 - x^2)], Abs[x] < 1}, {0, Abs[x] >= 1}}], {x, -2, 2},
AxesLabel -> {x, r[x]},
Filling -> {1 -> {Axis, Black}}, Axes -> False];
im2 = image;
Plot[Piecewise[{{Exp[-1/(1 - x^2)], Abs[x] < 1}, {0, Abs[x] >= 1}}], {x, -2, 2}]]


but with no success.

• – Jens
Dec 10, 2016 at 1:26

I would use ParametricPlot[] for this:

tex = Import["https://i.stack.imgur.com/kbuF9.jpg"]

ParametricPlot[{t x, t Piecewise[{{Exp[-1/(1 - x^2)], Abs[x] < 1}, {0, Abs[x] >= 1}}]},
{t, 0, 1}, {x, -2, 2}, AspectRatio -> 1/GoldenRatio, Axes -> None,
PlotStyle -> {Opacity, Texture[tex]},
TextureCoordinateFunction -> ({#1, #2} &)] Try using a region plot (I used an example texture but you could but any image in there):

RegionPlot[
y < Piecewise[
{
{Exp[-1/(1 - x^2)], Abs[x] < 1},
{0, Abs[x] >= 1}
}
] && y > 0,
{x, -2, 2},
{y, 0, 0.4},
PlotStyle -> Texture[ExampleData[{"ColorTexture", "Roof"}]]
] You could use Show with Plot if you want the styling of a plot overlaid with it, and Ticks, Frame and AspectRatio to directly modify the RegionPlot to get closer to a Plot style.