Message Boards Message Boards

0
|
3107 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Contour calculations and RegionFunction

Posted 10 years ago
When a ContourPlot is restricted to a region, the contour levels are still being calculated based on data values from the entire rectangular field. I think it would be more useful if they were calculated from data values as restricted by the specified RegionFunction.

The attached notebook is an example. x^3 + y^3 is plotted over the unit square, with the region restricted to an enclosed disk. But contours are clearly calculated from the unrestricted data. This is of course a simple example of another data set I'm working with.

Attachments:
POSTED BY: David Keith
3 Replies

This

In[167]:= Plot[f[x, y], {x, -1, 1}, {y, -1, 1},RegionFunction -> Function[{x, y}, x^2 + y^2 <= (1/2)^2],
    Contours -> Range[1/32 - 0.025, 1/32, 0.005 ], PlotRange -> {{-3/5, 3/5}, {-3/5, 3/5}}]

will do it because of

In[166]:= f[x, x] /. Last[Solve[2 x^2 == (1/2)^2, x, Reals]]
Out[166]= 1/32

because of the symmetry coincidence.

Attachments:
POSTED BY: Udo Krause

Hi,

in the Cloud (and probably in MMA 10 ?) this will work as well:

f[x_, y_] := x^4 + y^4;   
R = ImplicitRegion[x^2 + y^2 < 0.5^2, {x, y}];

and then

ContourPlot[f[x, y], {x, y} \[Element] R , Contours -> (FindDivisions[{#1, #2}, 10] &), ColorFunction -> "Rainbow"]

enter image description here

I suppose that it is actually useful to have the two options for plotting. The RegionFunction does not change the colours and with ImplicitRegion you can actually restrict your calculation to the domain you are interested in.

M.

POSTED BY: Marco Thiel
Posted 10 years ago

Yes! Very nice, Marco. Thanks.

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract