Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

    Manipulate[
 Show[{
   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. –  Pickett Nov 8 '13 at 13:45
add comment

1 Answer 1

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.

Manipulate[
  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
add comment

Your Answer

 
discard

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.