#!/usr/bin/env python
# coding: utf-8
# #### New to Plotly?
# Plotly's Python library is free and open source! [Get started](https://plotly.com/python/getting-started/) by downloading the client and [reading the primer](https://plotly.com/python/getting-started/).
# You can set up Plotly to work in [online](https://plotly.com/python/getting-started/#initialization-for-online-plotting) or [offline](https://plotly.com/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plotly.com/python/getting-started/#start-plotting-online).
# We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!
# #### Version Check
# Plotly's python API is updated frequesntly. Run pip install plotly --upgrade to update your Plotly version.
# In[1]:
import plotly
plotly.__version__
# #### Basic Quiver Plot
# In[2]:
import plotly.plotly as py
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)
py.iplot(fig, filename='Quiver Plot Example')
# #### Quiver Plot with Points
# In[3]:
import plotly.plotly as py
import plotly.figure_factory as ff
import plotly.graph_objs 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=dict(width=1))
# Create points
points = go.Scatter(x=[-.7, .75], y=[0,0],
mode='markers',
marker=dict(size=12),
name='points')
# Add points to figure
fig['data'].append(points)
py.iplot(fig, filename='Quiver with Points')
# #### Reference
# In[4]:
help(ff.create_quiver)
# In[5]:
from IPython.display import display, HTML
display(HTML(''))
display(HTML(''))
get_ipython().system(' pip install git+https://github.com/plotly/publisher.git --upgrade')
import publisher
publisher.publish(
'quiver.ipynb', 'python/quiver-plots/', 'Python Quiver Plots | plotly',
'How to make a quiver plot in Python. A quiver plot displays velocity vectors a arrows. ',
title = 'Python Quiver Plots | plotly',
name = 'Quiver Plots',
has_thumbnail='true', thumbnail='thumbnail/quiver-plot.jpg',
language='python',
display_as='scientific', order=12,
ipynb= '~notebook_demo/42')
# In[ ]: