Plotly Graphing Library in Python/v3
Get started with IPython notebooks and Plotly for inline interactive graphing.
Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Sign up for early access now.
Note: this page is part of the documentation for version 3 of Plotly.py, which is not the most recent version.
See our Version 4 Migration Guide for information about how to upgrade.
See our Version 4 Migration Guide for information about how to upgrade.
Getting started
Instructions on how to install Plotly's Python package can be found on the Plotly for Python getting started page.
Creating an interactive graph inside IPython notebook
import plotly.plotly as py
from plotly.graph_objs import *
trace0 = Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17]
)
trace1 = Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
data = Data([trace0, trace1])
py.iplot(data, filename = 'basic-line') Click to copy
Converting a matplotlib graph into an interactive graph inside an IPython notebook
import matplotlib.pyplot as plt
import numpy as np
import plotly.plotly as py
n = 50
x, y, z, s, ew = np.random.rand(5, n)
c, ec = np.random.rand(2, n, 4)
area_scale, width_scale = 500, 5
fig, ax = plt.subplots()
sc = ax.scatter(x, y, c=c,
s=np.square(s)*area_scale,
edgecolor=ec,
linewidth=ew*width_scale)
ax.grid()
py.iplot_mpl(fig) Click to copy
Embedding a Plotly graph inside an IPython notebook
import plotly.tools as tls
tls.embed("https://plotly.com/~streaming-demos/4") Click to copy
