Ask Your Question
1

implicit_plot shows wrong equation at edge of plot

asked 2023-10-22 01:11:32 +0100

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?

edit retag flag offensive close merge delete

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 ( 2023-10-22 02:14:43 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-11-04 23:51:34 +0100

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)
edit flag offensive delete link more

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: 2023-10-22 01:01:27 +0100

Seen: 97 times

Last updated: Nov 04 '23