Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks.
We also have a quick-reference cheatsheet (new!) to help you get started!
Plotly's python package is updated frequently. Run pip install plotly --upgrade to use the latest version.
import plotly
plotly.__version__
'2.0.7'
import plotly.plotly as py
import plotly.graph_objs as go
from plotly import tools
import numpy as np
x = np.linspace(-5, 80, 10)
y = np.linspace(-5, 60, 10)
xGrid, yGrid = np.meshgrid(y, x)
z = xGrid ** 3 + yGrid ** 3
scene = dict(
xaxis=dict(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=True,
backgroundcolor='rgb(230, 230,230)'
),
yaxis=dict(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=True,
backgroundcolor='rgb(230, 230,230)'
),
zaxis=dict(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=True,
backgroundcolor='rgb(230, 230,230)'
)
)
fig = tools.make_subplots(rows=2, cols=2,
specs=[[{'is_3d': True}, {'is_3d': True}],
[{'is_3d': True}, {'is_3d': True}]])
# adding surfaces to subplots.
fig.append_trace(dict(type='surface', x=x, y=y, z=z, colorscale='Viridis',
scene='scene1', showscale=False), 1, 1)
fig.append_trace(dict(type='surface', x=x, y=y, z=z, colorscale='RdBu',
scene='scene2', showscale=False), 1, 2)
fig.append_trace(dict(type='surface', x=x, y=y, z=z, colorscale='YlOrRd',
scene='scene3', showscale=False), 2, 1)
fig.append_trace(dict(type='surface', x=x, y=y, z=z, colorscale='YlGnBu',
scene='scene4', showscale=False), 2, 2)
fig['layout'].update(title='subplots with different colorscales',
height=800, width=800)
fig['layout']['scene1'].update(scene)
fig['layout']['scene2'].update(scene)
fig['layout']['scene3'].update(scene)
fig['layout']['scene4'].update(scene)
py.iplot(fig, file_name='multiple_plots')
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/plotly/graph_objs/_deprecations.py:477: DeprecationWarning: plotly.graph_objs.Scene is deprecated. Please replace it with one of the following more specific types - plotly.graph_objs.Scene
This is the format of your plot grid: [ (1,1) scene1 ] [ (1,2) scene2 ] [ (2,1) scene3 ] [ (2,2) scene4 ]
See https://plotly.com/python/subplots/ for more information regarding subplots!
from IPython.display import display, HTML
display(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700" rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))
#!pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
'3d-subplots.ipynb', 'python/3d-subplots/', 'Python 3D Subplots | plotly',
'3D Subplots in Plotly',
title= '3D Subplots in Python | plotly',
name = '3D Subplots',
has_thumbnail='true', thumbnail='thumbnail/3d-subplots.jpg',
language='python',
display_as='3d_charts', order=0.104,
ipynb= '~notebook_demo/75')
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead. /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you "Save" this notebook before running this command? Remember to save, always save.