Ask Your Question
1

implicit_plot shows wrong equation at edge of plot

asked 1 year ago

Nate Eldredge gravatar image

I'm trying to implicit_plot a straight line, but am getting erroneous results when the line is at the edge of the plot region.

When I do

x,y = var('x y')`enter code here`
implicit_plot(y==2, (x,-0.1, 2), (y, -0.1, 2))

I get a plot with a vertical line at the right edge. (Unfortunately as a new user I can't post the image.) This is wrong since y == 2 should be a horizontal line at the top edge.

If I change the value slightly and do

implicit_plot(y==1.9), (x,-0.1, 2), (y, -0.1, 2))

I get a horizontal line near the top of the graph, as expected.

I also get correct results if I plot y==2 with ranges (x, -0.1, 2.1), (y, -0.1, 2.1) so that the line is not exactly at the edge.

Is this a bug that I should report, or is it somehow expected behavior?

Preview: (hide)

Comments

When I try this, I see "UserWarning: pathological contour plot of a function whose values all lie on one side of the sole contour; we are adding more plot points and perturbing your function values." So apparently things can go wrong when you try to plot solely on the edge of the region.

John Palmieri gravatar imageJohn Palmieri ( 1 year ago )

1 Answer

Sort by » oldest newest most voted
0

answered 1 year ago

slelievre gravatar image

The way implicit_plot works is by sampling the plotting region, and detecting sign changes.

So if the line to plot is at the edge of the region, it won't work.

Workaround: enlarge the region when plotting, then restrict the region when showing the plot.

Example:

sage: x, y = SR.var('x, y')
sage: p = implicit_plot(y == 2, (x, -0.1, 2), (y, -0.1, 2.1))
sage: p.show(ymax=2)
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 1 year ago

Seen: 136 times

Last updated: Nov 04 '23