Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 308

Plotting Vector Fields in Sage

Sage has two commands for plotting vector fields. For 2D vector fields, use plot_vector_field((fx, fy), (x, x0, x1), (y, y0, y1)). I recommend also adding the option aspect_ratio=1 to make the window square.

var("x, y, z"); plot_vector_field((-y, x), (x,0, 2), (y, 0, 2), aspect_ratio=1)
(x, y, z)

For a 3D vector field, use plot_vector_field3d, as below. (This will be squared off by default.)

plot_vector_field3d((y, z, x), (x, -1, 1), (y, -1, 1), (z, -1, 1))
3D rendering not yet implemented
︠ccc652ca-1e1c-4b47-9bf0-09545dc43f73︠ ︠73e77507-8a0b-4a49-b48f-9bb207930734︠