Ask Your Question
0

contour plot not working as expected

asked 2012-05-07 04:34:12 +0100

sagemb gravatar image

updated 2013-06-03 11:33:31 +0100

tmonteil gravatar image

Hi all,

I am looking at ways to determine the sign of an angle between a reference vector (a,b) and any other vector(x,y) of the plane. To do so, I have decided to use the determinant of the matrix: [[a b],[x y]] which equals ax-by. I wanted then to check that the formula works by displaying the plane area which positive and negative signs using the contour_plot.

Here is my question:

Why is the 3rd graph not showing 2 horizontal areas instead of the vertical displayed?

var('x y')
f(x,y,a,b)=(a*y-b*x)/abs(a*y-b*x)
plota1b1=contour_plot(f(x,y,1,1),(-10,10),(-10,10),cmap='jet',colorbar=true)
plota0b1=contour_plot(f(x,y,0,1),(-10,10),(-10,10),cmap='jet',colorbar=true)
plota1b0=contour_plot(f(x,y,1,0),(-10,10),(-10,10),cmap='jet',colorbar=true)
show(plota1b1)
show(plota0b1)
show(plota1b0)

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2012-05-07 10:43:17 +0100

sagemb gravatar image

Oh, I see. Thank you very much!

BR M

edit flag offensive delete link more

Comments

1

Go ahead and check that as an answer if you feel like it answers your question.

Jason Grout gravatar imageJason Grout ( 2012-05-07 19:48:14 +0100 )edit
0

answered 2012-05-07 10:32:36 +0100

Jason Grout gravatar image

The problem is the way you are calling contour plot. Notice that f(x,y,1,0) is y/abs(y). When you are calling contour plot, you aren't specifying which range goes with which variable, so it assumes that the first numeric range (the horizontal axis) goes with the first variable in the expression, which is y.

The solution is to specify explicitly that the horizontal axis corresponds with the x variable, and the vertical axis is for the y variable:

plota1b0=contour_plot(f(x,y,1,0),(x,-10,10),(y,-10,10),cmap='jet',colorbar=true)

See a live example

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

Stats

Asked: 2012-05-07 04:34:12 +0100

Seen: 463 times

Last updated: May 07 '12