ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 07 Mar 2015 01:13:26 +0100plot surface plus vector fieldhttps://ask.sagemath.org/question/26056/plot-surface-plus-vector-field/My apologies for posting a (hopefully) simple question. I want to plot a surface with the gradient field in the plane underneath. I can create the surface and vector field separately, but I get an error when I try to show them on the same axes. It seems that the vector field is a different type. Does anyone know how to induce the vector field so it can be plotted as part of a 3d plot?
I'd like to do something like this:
f(x,y)=y/(1-x+y)
P=plot3d(f(x,y),(x,0,1),(y,0,1))
gradf=vector([y/(x-y-1)^2,(1-x)/(x-y-1)^2])
VF=plot_vector_field(gradf,(x,0,1),(y,0,1))
show(P+VF)
Everything but that last step works great, and then I get an error message:
NotImplementedError: 3D plotting not implemented for PlotField defined by a 20 x 20 vector grid
Can anyone suggest a workaround? Thanks for your help!Fri, 06 Mar 2015 22:45:30 +0100https://ask.sagemath.org/question/26056/plot-surface-plus-vector-field/Answer by tmonteil for <p>My apologies for posting a (hopefully) simple question. I want to plot a surface with the gradient field in the plane underneath. I can create the surface and vector field separately, but I get an error when I try to show them on the same axes. It seems that the vector field is a different type. Does anyone know how to induce the vector field so it can be plotted as part of a 3d plot?</p>
<p>I'd like to do something like this:</p>
<pre><code>f(x,y)=y/(1-x+y)
P=plot3d(f(x,y),(x,0,1),(y,0,1))
gradf=vector([y/(x-y-1)^2,(1-x)/(x-y-1)^2])
VF=plot_vector_field(gradf,(x,0,1),(y,0,1))
show(P+VF)
</code></pre>
<p>Everything but that last step works great, and then I get an error message:</p>
<pre><code>NotImplementedError: 3D plotting not implemented for PlotField defined by a 20 x 20 vector grid
</code></pre>
<p>Can anyone suggest a workaround? Thanks for your help!</p>
https://ask.sagemath.org/question/26056/plot-surface-plus-vector-field/?answer=26057#post-id-26057When you sum a 2d plot with a 3d plot, Sage tries to embed the 2d plot in the 3d space, with the [plot3d method](http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html#sage.plot.graphics.Graphics.plot3d). Unfortunately, this is not implemented for plot defined by vector fields (yet):
sage: VF.plot3d()
NotImplementedError: 3D plotting not implemented for PlotField defined by a 20 x 20 vector grid
A workaround is to define your vector field in 3d and plot it near the plane $z=0$:
sage: gradf = vector([y/(x-y-1)^2, (1-x)/(x-y-1)^2, 0])
sage: z = SR.symbol('z')
sage: VF = plot_vector_field3d(gradf, (x,0,1), (y,0,1), (z,0,0.0001), plot_points=10)
sage: show(P+VF)
Sat, 07 Mar 2015 01:13:26 +0100https://ask.sagemath.org/question/26056/plot-surface-plus-vector-field/?answer=26057#post-id-26057