Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an interactive demonstration, which (very simplified to leave out unnecessary details) looks as follows:

   Plot[{x, a*x}, {x, -1, 1}, PlotRange -> {-1, 1}],
   RegionPlot[x < y < a*x, {x, -1, 1}, {y, -1, 1}]
   }], {a, 0.5, 1.5}]

On the screen I see this: enter image description here.

I draw the arrow to point out a defect in the shading: the shading does not cover a narrow triangle in the vicinity of the coordinates origin, though it should.

More than that. The degree of shading varies as I move the slider.

I could, of course, use the option "Filling" in the Plot statement and remove the RegionPlot at all. I need, however, the filling to show the region where one of the lines is above the other. It seemed that the RegionPlot is in this case a more natural choice.

Can you imagine a workaround with the RegionPlot, or I should inevitably go to Filling in the Plot statement?

share|improve this question
fyi: $PerformanceGoal switches to "Speed" when you move the slider, that is why the degree of shading varies. – Kuba Nov 8 '13 at 10:39
PlotPoints->100 works OK for example. – C. E. Nov 8 '13 at 13:45
up vote 3 down vote accepted

You can play with PlotPoints, MaxRecurrsion etc. but this will slow you down. I think RegionPlot just doesn't fit here well.

I would use Filling, notice that I've change the order of functions in Plot so the White filling is on top.

  Plot[{a*x, x}, {x, -1, 1}, PlotRange -> {-1, 1}, PlotStyle -> {Red, Blue}, 
                             Filling -> {2 -> {Bottom, White}, 1 -> {Bottom, Orange}}, 
                             BaseStyle -> Thick]
  , {a, 0.5, 1.5}]

enter image description here

share|improve this answer
Thank you, and it is a pity. In a trough case I have with all its conditions the RegionPlot fits more natural. – Alexei Boulbitch Nov 11 '13 at 7:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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