3
$\begingroup$

I want to find the output of RegionPlot for a simple condition namely n*(x + y) < 1, where n is a varying number.

Here I have used Manipulate command in order to generate multiple RegionPlots (with different areas) for varying n values.

Manipulate[RegionPlot[{nx + ny < 1}, {x, -1, 1}, {y, -1, 1}], {n, 1, 10, 0.1}]

Now I want to generate a single region whose area changes with n for all values n=1..10, and also its color (or color intensity) varies as n changes.

So for example, as n decreases the intensity of the color decreases and this intensity is shown as a Legend near the diagram.

Can anyone help me with this issue?

Thank you so much.

$\endgroup$
3
$\begingroup$
Clear["Global`*"]

Manipulate[
 RegionPlot[{n*x + n*y < 1}, {x, -1, 1}, {y, -1, 1},
  PlotStyle -> ColorData["Rainbow"][Rescale[n, {1, 10}]]], {{n, 5}, 1,
   10, 0.1, Appearance -> "Labeled"}]

enter image description here

Legended[
 Show[
  RegionPlot[
     {#*x + #*y < 1}, {x, -1, 1}, {y, -1, 1},
     PlotStyle -> ColorData["Rainbow"][Rescale[#, {1, 10}]],
     PlotPoints -> 75,
     MaxRecursion -> 5] & /@ Range[10]],
 SwatchLegend[
  ColorData["Rainbow"][Rescale[#, {1, 10}]] & /@ Range[10], 
  Range[10]]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you Bob, is it possible to make the jumps between colors continues so that the change in color occurs more smoothly? $\endgroup$ – user14750 Apr 15 at 22:26
3
$\begingroup$

To get the continues effect I think we need to use ColorFunction,here we try the LinearGradientFilling .

normal = {1, 1};
Manipulate[
 Region[Style[ImplicitRegion[n*normal . {x, y} < 1, {x, y}], 
   LinearGradientFilling[ColorData["Rainbow"] /@ Range[0, 1, .1], 
    ArcTan @@ normal]], PlotRange -> All], {n, 1, 10, .1}]
$\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.