Hello,
Is there a command to save a plot generated by parametric_plot3d()? Like, say:
P = parametric_plot3d([x,y,z],(u,-10.0,10.0),(v,-10.0,10.0),plot_points=[50,50],frame=False,color=(fc,colormaps.jet))
P.save('somename.png')
#---------- Script begins here ----------#
from time import time
u,v = var('u','v')
a = var('a')
a = 0.2
a2 = (1.0 - a*a)
sa2 = sqrt(a2)
print "<html><h3>Breather Surface</h3></html>"
def x(u,v) :
return -u + (2.0*a2*cosh(a*u)*sinh(a*u))/(a*((a2*(cosh(a*u))^2 + a*a*(sin(sa2*v))^2)))
def y(u,v) :
return 2.0*sa2*cosh(a*u)*(-sa2*cos(v)*cos(sa2*v) - sin(v)*sin(sa2*v))/(a*((a2*(cosh(a*u))^2 + a*a*(sin(sa2*v))^2)))
def z(u,v) :
return 2.0*sa2*cosh(a*u)*(-sa2*sin(v)*cos(sa2*v) + cos(v)*sin(sa2*v))/(a*((a2*(cosh(a*u))^2 + a*a*(sin(sa2*v))^2)))
def fc(u,v) : # Colour scheme called by parametric_plot3d
return abs(u)/30.0
t1 = time()
P = parametric_plot3d([x,y,z],(u,-30.0,30.0),(v,-160.0,160.0),plot_points=[250,250],frame=False,color=(fc,colormaps.jet))
P.show(viewer='jmol')
t2 = time()
print "a = ",a
print "Execution time: ", t2-t1, " seconds."
#---------- Script ends here ----------#
Volker (or someone else) what is going on here with the display hook -
shouldn't *some* graphic, even an empty one, show up here, even if my made-up input makes no sense?
Volker (or someone else) what is going on here with the display hook -parametric_plot does note perform adequate input checking, leading to the construction of a graphics3d object with bogous state.shouldn't *some* graphic, even an empty one, show up here, even if my made-up input makes no sense?I don't think so, the normal Python way is to show you a backtrace so you can fix your mistake and not make up random default return values.
The problem here is of course that the color function fc must be a function of two arguments instead of one.
I can reproduce the crash, presumably you opened a bug for that?
Here is an example that works. It plots an image. What I had in mind was to replace P.show(...) by P.save(...) and, instead of displaying the image, saving it.
The replacement dDidn't work out though. Needless to say, the script below runs on Sage's notebook.
I don't think so, the normal Python way is to show you a backtrace so you can fix your mistake and not make up random default return values.If there is an error, but that's not what (apparently) happened here, only a warning. In which event it should raise an Error of some kind, but it didn't (did it?) and not return anything.
Here is an example that works. It plots an image. What I had in mind was to replace P.show(...) by P.save(...) and, instead of displaying the image, saving it.
The replacement dDidn't work out though. Needless to say, the script below runs on Sage's notebook.As I expected, P.save() worked fine. You do have to provide a filename/location.sage: P.save('/Users/myname/test.png')
sage: P.save('/Users/myname/test.png')
Well, I did that since the beginning and yet no image was ever saved. Could that be related to the fact that I run my script in the notebook? You seem to run it in Sage's prompt.