2
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ fyi: $PerformanceGoal switches to "Speed" when you move the slider, that is why the degree of shading varies. $\endgroup$ – Kuba Nov 8 '13 at 10:39
  • $\begingroup$ PlotPoints->100 works OK for example. $\endgroup$ – C. E. Nov 8 '13 at 13:45
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thank you, and it is a pity. In a trough case I have with all its conditions the RegionPlot fits more natural. $\endgroup$ – Alexei Boulbitch Nov 11 '13 at 7:52

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.