6
$\begingroup$

There are three curves in this figure.

enter image description here

I use the followed code to fill the gap:

Emin = (6)^2 - (wk + 2)^2; Emax1 = (6)^2; Emax2 = (6)^2 - (wk - 2)^2;
p[x_, left_, right_] :=HeavisideTheta[x - left] HeavisideTheta[right - x];
Plot[{Emin p[wk, 0, 4], Emax1 p[wk, 0, 2], Emax2 p[wk, 2, 4]}, {wk, 0, 4}, 
     Filling -> {1 -> {{2}, {Pink, White}}, 1 -> {{3}, {Pink, White}}}]

Then, I get the figure, which is almost what I want. It would be better if there is no line at the boundary.

How can I fill the gap without the line at the boundary?

enter image description here

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Aug 7 '15 at 7:21
10
$\begingroup$
p[x_, left_, right_] := If[left < x < right, 1, Undefined]

Plot[{Emin p[wk, 0, 4], Emax1 p[wk, 0, 2], Emax2 p[wk, 2, 4]}, {wk, 0, 4}, 
      Filling -> {1 -> {{2}, Pink}, 1 -> {{3}, Pink}}]

Mathematica graphics

Edit

You may also use for example the more idiomatic

p[x_, left_, right_] := 1 /; left < x < right

for the same purpose. What you need is a function that is constant in an interval and has no numeric value outside it, so Filling can't act.

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