3

First, I should say I am at best an advanced amateur at Mathematica, and that generally speaking my knowledge of programming (in any language) is more in computation than visualization.

There is a model I am working on for which I have recently shown there is a feasibility region: $$\mathcal{R} = \{(x,y) \in [0,\infty)\times[0, \infty) : x+y \leq L\}.$$ Of course this is a triangular subregion of the first quadrant. I wish to restrict the domain of the streamplots I am generating to $\mathcal{R}$.

From looking at the documentation I have constructed the following code:

StreamPlot[{dx/dt, dy/dt}, {x, 0, L}, {y, 0, L}]

which works fine, but of course gives me a large amount of unneeded data that clutters up my attempted visualization. So then, my question is:

How do I restrict the domain of StreamPlot to $\mathcal{R} $?

Johu
  • 4,918
  • 16
  • 43
GeauxMath
  • 133
  • 2

2 Answers2

4
StreamPlot[{-1 - x^2 + y, 1 + x - y^2}, {x, -3, 3}, {y, -3, 3}, 
 RegionFunction -> Function[{x, y, z}, 2 < x^2 + y^2 < 9]]

enter image description here

or

StreamPlot[{-1 - x^2 + y, 1 + x - y^2}, {x, y} \[Element] 
  StadiumShape[{{0, 0}, {2, 3}}, 2]]

enter image description here

Johu
  • 4,918
  • 16
  • 43
1

Try

StreamPlot[{dx/dt, dy/dt}, {x, 0, L}, {y, 0, L}, RegionFunction -> Function[{x, y}, x+y <= L]]
NonDairyNeutrino
  • 7,810
  • 1
  • 14
  • 29