4
$\begingroup$

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}]

enter image description here

with the texture:

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;
ImageMultiply[ImageAdd[im1, im2], 
Plot[Piecewise[{{Exp[-1/(1 - x^2)], Abs[x] < 1}, {0, Abs[x] >= 1}}], {x, -2, 2}]]

but with no success.

$\endgroup$
7
$\begingroup$

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[1], Texture[tex]},
               TextureCoordinateFunction -> ({#1, #2} &)]

Mathematica graphics

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

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"}]]
]

Texture

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.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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