Contour Plots and Points

i like this post (click again to cancel)
1
i dont like this post (click again to cancel)

Why can I not have a single point on a contour plot?

var('x,y')

f(x,y)=sin(x)*cos(y)

G = contour_plot(f(x,y),(x,-3,3),(y,-3,3),contours=20,plot_points=100)

G += point((1,1), size=100) 

G.show()

does not display the point. I can add a line (for example)

G += line(((1.5,1),(1.5,0)))

and that line shows up but not the point.

Thanks.

JT

asked Jan 15 '12

travis gravatar image travis
23 5
http://math.mc.edu/travis

updated Jan 15 '12

DSM gravatar image DSM flag of Canada
4802 12 61 103

2 Answers:

i like this answer (click again to cancel)
4
i dont like this answer (click again to cancel) travis has selected this answer as correct

The point is there -- it's simply lurking behind the contour plot. Or, in matplotlib jargon (one of the plotting packages Sage uses is called matplotlib), it doesn't have a higher zorder. The zorder is the layer level, where the layers are drawn from lower to higher.

I can never remember what zorders different things default to, but it's usually easily changed manually:

var('x,y')
f(x,y)=sin(x)*cos(y)
G = contour_plot(f(x,y),(x,-3,3),(y,-3,3),contours=20,plot_points=100)
G += point((1,1), size=100,zorder=2)
G.show()

produces

image description

link

posted Jan 15 '12

DSM gravatar image DSM flag of Canada
4802 12 61 103
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

Thanks.

Just to be certain, why does subsequently plotting a line without a zorder not put that line behind the contour plot as well?

link

posted Jan 16 '12

travis gravatar image travis
23 5
http://math.mc.edu/travis

Unfortunately I don't understand the order in which things are drawn well enough to say what the order is when zorders aren't specified/things have the same zorder. Note that you can use the ".set_zorder" method on graphics objects to change it after-the-fact.

DSM (Jan 16 '12)
1

it seems to make sense to have contour plots below other things generally. It would be great if someone came up with a comprehensive sensible default zorder for all of the graphics objects.

Jason Grout (Jan 16 '12)

Agreed. But who will take the responsibility for user complaints that that zorder setup is wrong?

kcrisman (Jan 17 '12)

the same person that does now...the user who wants to submit a patch.

Jason Grout (Apr 12 '12)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Jan 15 '12

Seen: 146 times

Last updated: Jan 16 '12

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.