Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Inconsistent behavior of RegionFunction in ContourPlot and ListContourPlot
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Alexey

Posts: 265
Registered: 6/14/08
Inconsistent behavior of RegionFunction in ContourPlot and ListContourPlot
Posted: Aug 18, 2012 3:44 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello folks,

When trying to plot a non-covex set of datapoints ListContourPlot produces a
convex graph effectively extrapolating values outside of the actual range of
the original dataset:

pts = {{1, 1, 1}, {2, 1.2, .8}, {3, 1.3, .7}, {3, 2, 1}, {1.5, 2,
1}, {1.5, 1.5, 1}};
epilog = {FaceForm[None], EdgeForm[Red], Polygon[Most /@ pts]};
ListContourPlot[pts, Epilog -> epilog]

(the red polygon shows the actual range of the data).

I need to remove the extrapolated parts of the graph and define
RegionFunction:

leftBorder =
Interpolation[pts[[{5, 6, 1}, {2, 1}]], InterpolationOrder -> 1];
bottomBorder =
Interpolation[pts[[{1, 2, 3}, {1, 2}]], InterpolationOrder -> 1];
ListContourPlot[pts, Epilog -> epilog,
RegionFunction ->
Function[{x, y, z},
x >= leftBorder[y] && y >= bottomBorder[x]]]

But as you see, nothing happens! The drawn region of the plot still contains
areas outside of the area allowed by the RegionFunction.

There is no such problem with ContourPlot:

ContourPlot[Sin[x y], {x, 1, 3}, {y, 1, 2}, Epilog -> epilog,
RegionFunction ->
Function[{x, y, z}, x >= leftBorder[y] && y >= bottomBorder[x]]]

Is it a bug in ListContourPlot? How to achieve consistent behavior of
RegionFunction in both ContourPlot and ListContourPlot?

Thanks in advance!






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.