4
$\begingroup$

Is it possible to obtain something similar to what I show below with Mathematica?

enter image description here

$\endgroup$
  • $\begingroup$ Yes. Where are you stuck? $\endgroup$ – Kuba Jan 31 '17 at 13:27
  • $\begingroup$ Basically, I started with RegionPlot and I continue with Plot[-(2/3) x + 6, {x, -5, 15}, Filling -> Axis]. But I cannot find how to better manipulate the filling option, let alone how to create this "randomly" looking region. $\endgroup$ – Dimitris Jan 31 '17 at 13:32
10
$\begingroup$

I would use the RegionPlot and add some additional condition on the region you want to show. For example:

Show[
  RegionPlot[
    2 x + 3 y < 6 && 
    Sqrt[0.9 (x - 1.2)^2 + (y - 1)^2] < 3 + 0.2 Sin[6 ArcTan[x - 1, y - 1]],
    {x, -3, 5}, {y, -3, 5}, 

    Axes -> True,
    AxesOrigin -> {0, 0},
    Frame -> False, 
    AxesLabel -> {x, y},
    PlotRange -> {{-2, 4}, {-2, 4}}, 
    PlotRangeClipping -> False,
    ImagePadding -> 20,
    PlotPoints -> 40, 
    BoundaryStyle -> None],

  Plot[y /. Solve[2 x + 3 y == 6, y], {x, -1.45, 3.85}],
  Graphics[Rotate[Text[2 x + 3 y == 6, {1.3, 1.4}], -35 Degree]]
]

Random region plot

Of course choosing the clipping region may be the biggest challenge. Here I used equation for a circle, and added some wiggles with sine.

$\endgroup$
  • $\begingroup$ Thank you very much! Exactly what I wanted. $\endgroup$ – Dimitris Jan 31 '17 at 17:00
4
$\begingroup$

If you are willing to accept a shaded half-plane in place of an irregular region, it is relatively easy.

Module[{pts},
  pts = {x, y} /. FindInstance[2 x + 3 y == 6, {x, y}, Reals, 2];
  Graphics[
    {{GrayLevel[.8], HalfPlane[pts, {+1, -1}]},
     InfiniteLine[pts],
     Rotate[
       Inset[
         Style[TraditionalForm[2 x + 3 y == 6], 14], 
         .5 ({0, 2} + {3, 0}) + .2 {1, 1}], 
       ArcTan[-2/3]]},
    PlotRange -> {{-4, 5}, {-3, 5}},
    Axes -> True]]

graphics

Update

Plot and Filling and be used to do this, too. You simply have to use a different set of options.

Plot[2 - 2 x/3, {x, -4, 5},
  AspectRatio -> Automatic,
  PlotRange -> {Automatic, {-3, 5}},
  Filling -> Bottom,
  Epilog -> 
    {Rotate[
       Inset[
         Style[TraditionalForm[2 x + 3 y == 6], 14], 
         .5 ({0, 2} + {3, 0}) + .2 {1, 1}], 
       ArcTan[-2/3]]}]

plot

$\endgroup$
  • $\begingroup$ Thanks a lot for your workaround. But just from curiosity: Why Filling does not support something similar? $\endgroup$ – Dimitris Jan 31 '17 at 17:02
  • $\begingroup$ @dimitris You can use the PlotRange to properly pan the region in the RegionPlot: RegionPlot[2 x + 3 y < 6, {x, -3, 5}, {y, -3, 5}, PlotRange -> {{-2, 4}, {-2, 4}}, Frame -> False, Axes -> True, AxesLabel -> {x, y}, Epilog -> Inset[Rotate[2 x + 3 y < 6, -35 Degree], {1.3, 1.4}] ] $\endgroup$ – mszynisz Jan 31 '17 at 17:15
  • $\begingroup$ Perfect. Why you don't post it as a reply? $\endgroup$ – Dimitris Jan 31 '17 at 17:25
  • $\begingroup$ @dimitris. Filling does not support something similar; see my update. $\endgroup$ – m_goldberg Jan 31 '17 at 17:30
  • $\begingroup$ @m_goldberg: Thanks for the update. All the workarounds are very useful. $\endgroup$ – Dimitris Jan 31 '17 at 21:59

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.