0
$\begingroup$

Suppose I have the following function:

DC[x_, y_] := 3 x - y
sigma[x_, y_, z_, d_] := 3 DC[x, y] + 5 z + d

I made list of sigma[x, y, 3, 3] versus x with a condition on DC[x,y] by:

T = Table[{x, If[-50 < DC[x, y] < 50, sigma[x, y, 2, 3]]}, 
            {x, -5, -2,1},{y,2, 6, 1}];

Then

ListPlot[T] gives:

enter image description here

The problem, I don't want a graph like the previous one, alternatively, I 'd like to make a graph like:

enter image description here

with the area between lines shaded,i.e., I'd like to plot the region between the maximum and minimum scatter points of the function ..

Like for instance this plot:

enter image description here

I think I should use from beginning some command rather than ListPlot, like RegionPlot ?

$\endgroup$
  • $\begingroup$ I suppose adding Filling->{1->{2}} can make this graphics better in style? @ss $\endgroup$ – Wjx Jun 8 '16 at 10:27
  • $\begingroup$ In your latter case, Filling->Axis will do the job $\endgroup$ – Wjx Jun 8 '16 at 10:46
  • $\begingroup$ FillingForm can change the properties of your Filling $\endgroup$ – Wjx Jun 8 '16 at 10:47
1
$\begingroup$
lines = Sort[#, #1[[2]] < #[[2]] &][[{1, -1}]] & /@ T;
top = lines[[All, 1]];
bot = lines[[All, 2]];
Show[ListPlot[T],
ListLinePlot[{top, bot}, Filling -> {1 -> {2}}]]

enter image description here

Or you can use ConvexHullMesh to get the region where all the points are.

Show[ConvexHullMesh[Flatten[T, 1]], ListPlot[T],
      AspectRatio -> 0.75, Frame -> True]

enter image description here

For Mathematica 7

Needs["ComputationalGeometry`"]
T1 = Flatten[T, 1];
ListPlot[T1, Prolog -> {Opacity[0.3], Blue, Polygon[T1[[#]] & /@ ConvexHull[T1]]}]
$\endgroup$
  • $\begingroup$ Actually from the beginning can I use some command instead of ListPlot, because I don't want these points. Rather I want to make "shaded" region $\endgroup$ – S.S. Jun 8 '16 at 10:13
  • $\begingroup$ use Filling. I modified my answer. $\endgroup$ – Sumit Jun 8 '16 at 10:35
  • $\begingroup$ I'm also modified my question, please look at .. $\endgroup$ – S.S. Jun 8 '16 at 10:38
  • $\begingroup$ You can not use RegionPlot here, because it is not a single function you are plotting. You have multiple parameter value and each will describe one condition. So you will end up with combining 5 different regions. $\endgroup$ – Sumit Jun 8 '16 at 10:49
  • $\begingroup$ So can I just make a smooth curve a round the scatter points, like the attached blue plot .. $\endgroup$ – S.S. Jun 8 '16 at 10: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.