Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Points making up a plot

I'd like to get the list of points that make up a sage plot so I can process it through LaTeX (eg pgfplots) and get a better looking plot. This post here is essentially what I'm looking. I didn't really understand the code but came up with this:

x,y=var('x,y')
f(x,y)=x^2-y^2
p = implicit_plot(f(x,y)==3,(x,-3,3),(y,-3,3),plot_points=300)
P = p.matplotlib()
R = P.get_children()[1]
S = R.collections[0]
r = S.get_paths()[0]
v = r.vertices
xvals = v[:,0]
yvals = v[:,1]

Change the function to f(x,y)=x^2+y^2 and the code works properly. But the example above only gives me the list of points for the left half of the hyperbola. How can I get the list of points when the graph is disconnected? Can that be extended to get the list of points if there are multiple graphs in the same plot?