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.Sun, 08 Apr 2018 12:21:16 +02003D Vector Field Doesn't have Arrowshttps://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/I have been trying to plot 3D vector fields, but I keep running into a problem. The graphic does not have arrows instead it is just lines.
Here is the code.
var('x,y,z')
p = plot_vector_field3d((x,y,z), (x, -5, 5), (y, -5, 5), (z, -5, 5))
p.show()
Sat, 07 Apr 2018 04:01:14 +0200https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/Comment by slelievre for <p>I have been trying to plot 3D vector fields, but I keep running into a problem. The graphic does not have arrows instead it is just lines.
Here is the code.</p>
<pre><code>var('x,y,z')
p = plot_vector_field3d((x,y,z), (x, -5, 5), (y, -5, 5), (z, -5, 5))
p.show()
</code></pre>
https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?comment=41905#post-id-41905Welcome to Ask Sage! Thank you for your question!Sat, 07 Apr 2018 21:09:34 +0200https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?comment=41905#post-id-41905Answer by slelievre for <p>I have been trying to plot 3D vector fields, but I keep running into a problem. The graphic does not have arrows instead it is just lines.
Here is the code.</p>
<pre><code>var('x,y,z')
p = plot_vector_field3d((x,y,z), (x, -5, 5), (y, -5, 5), (z, -5, 5))
p.show()
</code></pre>
https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?answer=41899#post-id-41899The SageManifolds implementation of vector fields gives you a rendering with arrows.
See the gallery at
- [http://sagemanifolds.obspm.fr/gallery.html](http://sagemanifolds.obspm.fr/gallery.html)
There is ongoing work to make the SageManifolds approach the default for vector fields in Sage, see
- [Sage Trac ticket #24623](https://trac.sagemath.org/ticket/24623)Sat, 07 Apr 2018 11:40:03 +0200https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?answer=41899#post-id-41899Answer by eric_g for <p>I have been trying to plot 3D vector fields, but I keep running into a problem. The graphic does not have arrows instead it is just lines.
Here is the code.</p>
<pre><code>var('x,y,z')
p = plot_vector_field3d((x,y,z), (x, -5, 5), (y, -5, 5), (z, -5, 5))
p.show()
</code></pre>
https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?answer=41901#post-id-41901Until [#24623](https://trac.sagemath.org/ticket/24623) is ready, the minimal code to plot the proposed vector field within the manifold framework is (this works with Sage >= 7.5):
R3 = Manifold(3, 'R^3')
X.<x,y,z> = R3.chart()
v = R3.vector_field()
v[:] = (x,y,z)
p = v.plot(max_range=5, scale=0.5)
p.show()
It is a little bit slow, but thanks to some optimisations, this should be improved in future versions of Sage. See the [online doc](http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/differentiable/vectorfield.html#sage.manifolds.differentiable.vectorfield.VectorField.plot) for the list of all options of `v.plot()`. Note also that you can replace the last line by `p.show(viewer='threejs')`.Sat, 07 Apr 2018 13:25:06 +0200https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?answer=41901#post-id-41901Comment by eric_g for <p>Until <a href="https://trac.sagemath.org/ticket/24623">#24623</a> is ready, the minimal code to plot the proposed vector field within the manifold framework is (this works with Sage >= 7.5):</p>
<pre><code>R3 = Manifold(3, 'R^3')
X.<x,y,z> = R3.chart()
v = R3.vector_field()
v[:] = (x,y,z)
p = v.plot(max_range=5, scale=0.5)
p.show()
</code></pre>
<p>It is a little bit slow, but thanks to some optimisations, this should be improved in future versions of Sage. See the <a href="http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/differentiable/vectorfield.html#sage.manifolds.differentiable.vectorfield.VectorField.plot">online doc</a> for the list of all options of <code>v.plot()</code>. Note also that you can replace the last line by <code>p.show(viewer='threejs')</code>.</p>
https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?comment=41909#post-id-41909Once [#24623](https://trac.sagemath.org/ticket/24623) is merged in Sage, the above code will reduce to
E.<x,y,z> = EuclideanSpace(3)
v = E.vector_field((x,y,z))
v.plot(max_range=5, scale=0.5)Sun, 08 Apr 2018 12:21:16 +0200https://ask.sagemath.org/question/41898/3d-vector-field-doesnt-have-arrows/?comment=41909#post-id-41909