{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"#### New to Plotly?\n",
"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/).\n",
"
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).\n",
"
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"#### Basic Wireframe Plot"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import plotly.plotly as py\n",
"import plotly.graph_objs as go\n",
"\n",
"import numpy as np\n",
"\n",
"# Creating the data\n",
"x = np.linspace(-5, 5, 50)\n",
"y = np.linspace(-5, 5, 50)\n",
"xGrid, yGrid = np.meshgrid(y, x)\n",
"R = np.sqrt(xGrid ** 2 + yGrid ** 2)\n",
"z = np.sin(R)\n",
"\n",
"# Creating the plot\n",
"lines = []\n",
"line_marker = dict(color='#0066FF', width=2)\n",
"for i, j, k in zip(xGrid, yGrid, z):\n",
" lines.append(go.Scatter3d(x=i, y=j, z=k, mode='lines', line=line_marker))\n",
"\n",
"layout = go.Layout(\n",
" title='Wireframe Plot',\n",
" scene=dict(\n",
" xaxis=dict(\n",
" gridcolor='rgb(255, 255, 255)',\n",
" zerolinecolor='rgb(255, 255, 255)',\n",
" showbackground=True,\n",
" backgroundcolor='rgb(230, 230,230)'\n",
" ),\n",
" yaxis=dict(\n",
" gridcolor='rgb(255, 255, 255)',\n",
" zerolinecolor='rgb(255, 255, 255)',\n",
" showbackground=True,\n",
" backgroundcolor='rgb(230, 230,230)'\n",
" ),\n",
" zaxis=dict(\n",
" gridcolor='rgb(255, 255, 255)',\n",
" zerolinecolor='rgb(255, 255, 255)',\n",
" showbackground=True,\n",
" backgroundcolor='rgb(230, 230,230)'\n",
" )\n",
" ),\n",
" showlegend=False,\n",
")\n",
"fig = go.Figure(data=lines, layout=layout)\n",
"py.iplot(fig, filename='wireframe_plot')"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"#### Reference"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"See https://plotly.com/python/reference/#scatter3d for more information!"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting git+https://github.com/plotly/publisher.git\n",
" Cloning https://github.com/plotly/publisher.git to /var/folders/ld/6cl3s_l50wd40tdjq2b03jxh0000gp/T/pip-1sjqef8u-build\n",
"Installing collected packages: publisher\n",
" Found existing installation: publisher 0.11\n",
" Uninstalling publisher-0.11:\n",
" Successfully uninstalled publisher-0.11\n",
" Running setup.py install for publisher ... \u001b[?25l-\b \b\\\b \b|\b \bdone\n",
"\u001b[?25hSuccessfully installed publisher-0.10\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated. You should import from nbconvert instead.\n",
" \"You should import from nbconvert instead.\", ShimWarning)\n",
"/Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you \"Save\" this notebook before running this command? Remember to save, always save.\n",
" warnings.warn('Did you \"Save\" this notebook before running this command? '\n"
]
}
],
"source": [
"from IPython.display import display, HTML\n",
"\n",
"display(HTML(''))\n",
"display(HTML(''))\n",
"\n",
"! pip install git+https://github.com/plotly/publisher.git --upgrade\n",
" \n",
"import publisher\n",
"publisher.publish(\n",
" '3d-wireframe.ipynb', 'python/3d-wireframe-plots/', 'Python Wireframe Plots | plotly',\n",
" 'How to make wireframe plots in Python',\n",
" title= '3D Wireframe Plots in Python | plotly',\n",
" name = '3D Wireframe Plots',\n",
" has_thumbnail='true', thumbnail='thumbnail/wireframe.jpg', \n",
" language='python',\n",
" display_as='3d_charts', order=8,\n",
" ipynb= '~notebook_demo/68')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}