Skip to content

Latest commit

 

History

History
88 lines (71 loc) · 2.03 KB

quiver-plots.md

File metadata and controls

88 lines (71 loc) · 2.03 KB
jupyter
jupytext kernelspec language_info plotly
notebook_metadata_filter text_representation
all
extension format_name format_version jupytext_version
.md
markdown
1.1
1.2.3
display_name language name
Python 3
python
python3
codemirror_mode file_extension mimetype name nbconvert_exporter pygments_lexer version
name version
ipython
3
.py
text/x-python
python
python
ipython3
3.7.3
description display_as language layout name order permalink thumbnail
How to make a quiver plot in Python. A quiver plot displays velocity vectors a arrows.
scientific
python
base
Quiver Plots
10
python/quiver-plots/
thumbnail/quiver-plot.jpg

Quiver plots can be made using a figure factory as detailed in this page.

Basic Quiver Plot

import plotly.figure_factory as ff

import numpy as np

x,y = np.meshgrid(np.arange(0, 2, .2), np.arange(0, 2, .2))
u = np.cos(x)*y
v = np.sin(x)*y

fig = ff.create_quiver(x, y, u, v)
fig.show()

Quiver Plot with Points

import plotly.figure_factory as ff
import plotly.graph_objects as go

import numpy as np

x,y = np.meshgrid(np.arange(-2, 2, .2),
                  np.arange(-2, 2, .25))
z = x*np.exp(-x**2 - y**2)
v, u = np.gradient(z, .2, .2)

# Create quiver figure
fig = ff.create_quiver(x, y, u, v,
                       scale=.25,
                       arrow_scale=.4,
                       name='quiver',
                       line_width=1)

# Add points to figure
fig.add_trace(go.Scatter(x=[-.7, .75], y=[0,0],
                    mode='markers',
                    marker_size=12,
                    name='points'))

fig.show()

See also

Cone plot for the 3D equivalent of quiver plots.

Reference

For more info on ff.create_quiver(), see the full function reference