Message Boards Message Boards

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

How do you plot a non-function xRy relation

Is there a function in Mathematica that plots simple xRy relations that are not functions, like x==y^2 or x==3 or x^2+y^2==1? RegionPlot[] takes arguments like that but doesn't work for me unless the relation is an inequality.

POSTED BY: Jay Gourley
3 Replies

RegionPlot[] was originally designed to plot inequalities, and it does a pretty good job. When Region functionality was introduced in V10, RegionPlot[] was extended to plot (plane) regions. I see people recommending RegionPlot[reg], but I find it a bit shocking that it is not as robust as the following:

RegionPlot[
 DiscretizeRegion[ImplicitRegion[x == y^2, {x, y}]]
 ]

Another way to improve RegionPlot is to specify a plot range. In the ImplicitRegion I stole from Eric Rimbey, it takes the execution time down from 15+ sec. to 0.05 sec and produces a smooth graph:

RegionPlot[ImplicitRegion[x == y^2, {x, y}], 
 PlotRange -> {{0, 4}, {-2, 2}}]

I have sometimes thought RegionPlot[reg] was added with the purpose of adding a fast, not necessarily precise, rendering of the region. This example pretty much shows I was wrong. It's not even as fast as Region[reg], which takes 0.0001 sec. below:

Region[Style[ImplicitRegion[x == y^2, {x, y}], Directive[Red, Thick]]]
POSTED BY: Michael Rogers

Thanks, Eric. I agree ContourPlot[] works fine. RegionPlot[] sucks. ContourPlot[] answers my question.

POSTED BY: Jay Gourley
Posted 3 months ago

You can use RegionPlot with an ImplicitRegion:

RegionPlot[ImplicitRegion[x == y^2, {x, y}]]

As is typical with plotting regions, the result isn't very satisfying. You could discretize an implicit region:

DiscretizeRegion[ImplicitRegion[x == y^2, {x, y}]]

You might like ContourPlot better:

ContourPlot[x == y^2, {x, 0, 10}, {y, -10, 10}]
POSTED BY: Eric Rimbey
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