2
$\begingroup$

I have a vector plot and a region plot on the same scale and I wish to join them like when using Show[ , ]. Now, the vector plot has part outside the region that I would like to delete. Any idea how to do it ? Thanks !

Here repectively the region and vector plots:

enter image description hereenter image description here

The superimposition

enter image description here

So I would like to remove the segments of the lines lying outside the shaded area.

$\endgroup$
4
  • 1
    $\begingroup$ Please post your code. $\endgroup$
    – cvgmt
    Feb 22 at 2:01
  • $\begingroup$ Does something like StreamPlot[{x^2,y},Element[{x,y},ImplicitRegion[2x^3+y^2<1,{x,y}]],StreamScale->None] work? $\endgroup$
    – Adam
    Feb 22 at 2:02
  • $\begingroup$ @cvgmt I'm essentially using ListStreamPlot[list, StreamScale -> None, StreamColorFunction -> None] with some list (the result of a numerical integration of a PDE) and RegionPlot[W] for some parametric region W. $\endgroup$ Feb 22 at 2:05
  • $\begingroup$ @Adam It works, but I was looking for some solution after obtaining both plots. Getting each one of them takes considerable machine time so I did not want to run it again. $\endgroup$ Feb 22 at 2:07

1 Answer 1

4
$\begingroup$

Using the RegionFunction you can restrict the ListStreamPlot to a parametric region. I will have to create some data first.

ℛ = 
  ParametricRegion[{{s, (1 + t) s^2 - t}, -1 <= s <= 1 && 
     0 <= t <= 1}, {s, t}];

enter image description here

data = Table[{{x, y}, {y, x - y}}, {x, -1.5, 1.5, 0.2}, {y, -2, 2, 
    0.2}];
ListStreamPlot[data
 , AspectRatio -> Automatic
 ]

enter image description here

You can use RegionFunction like this:

ListStreamPlot[data
 , RegionFunction -> 
  Function[{x, y}, RegionMember[ℛ, {x, y}]]
 , AspectRatio -> Automatic
 ]

enter image description here

$\endgroup$
2
  • $\begingroup$ Excellent !!! Thank you so much. $\endgroup$ Feb 22 at 8:28
  • $\begingroup$ You are most welcome. Thanks for the accept. $\endgroup$
    – Syed
    Feb 22 at 8:29

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.