{ "cells": [ { "cell_type": "markdown", "metadata": {}, "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": {}, "source": [ "#### Vertical and Horizontal Lines Positioned Relative to the Axes" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "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", "trace0 = go.Scatter(\n", " x=[2, 3.5, 6],\n", " y=[1, 1.5, 1],\n", " text=['Vertical Line', 'Horizontal Dashed Line', 'Diagonal dotted Line'],\n", " mode='text',\n", ")\n", "data = [trace0]\n", "layout = {\n", " 'xaxis': {\n", " 'range': [0, 7]\n", " },\n", " 'yaxis': {\n", " 'range': [0, 2.5]\n", " },\n", " 'shapes': [\n", " # Line Vertical\n", " {\n", " 'type': 'line',\n", " 'x0': 1,\n", " 'y0': 0,\n", " 'x1': 1,\n", " 'y1': 2,\n", " 'line': {\n", " 'color': 'rgb(55, 128, 191)',\n", " 'width': 3,\n", " },\n", " },\n", " # Line Horizontal\n", " {\n", " 'type': 'line',\n", " 'x0': 2,\n", " 'y0': 2,\n", " 'x1': 5,\n", " 'y1': 2,\n", " 'line': {\n", " 'color': 'rgb(50, 171, 96)',\n", " 'width': 4,\n", " 'dash': 'dashdot',\n", " },\n", " },\n", " # Line Diagonal\n", " {\n", " 'type': 'line',\n", " 'x0': 4,\n", " 'y0': 0,\n", " 'x1': 6,\n", " 'y1': 2,\n", " 'line': {\n", " 'color': 'rgb(128, 0, 128)',\n", " 'width': 4,\n", " 'dash': 'dot',\n", " },\n", " },\n", " ]\n", "}\n", "\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "\n", "py.iplot(fig, filename='shapes-lines')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Lines Positioned Relative to the Plot & to the Axes" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "trace0 = go.Scatter(\n", " x=[2, 6],\n", " y=[1, 1],\n", " text=['Line positioned relative to the plot', \n", " 'Line positioned relative to the axes'],\n", " mode='text',\n", ")\n", "data = [trace0]\n", "layout = {\n", " 'xaxis': {\n", " 'range': [0, 8]\n", " },\n", " 'yaxis': {\n", " 'range': [0, 2]\n", " },\n", " 'shapes': [\n", " # Line reference to the axes\n", " {\n", " 'type': 'line',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'x0': 4,\n", " 'y0': 0,\n", " 'x1': 8,\n", " 'y1': 1,\n", " 'line': {\n", " 'color': 'rgb(55, 128, 191)',\n", " 'width': 3,\n", " },\n", " },\n", " # Line reference to the plot\n", " {\n", " 'type': 'line',\n", " 'xref': 'paper',\n", " 'yref': 'paper',\n", " 'x0': 0,\n", " 'y0': 0,\n", " 'x1': 0.5,\n", " 'y1': 0.5,\n", " 'line': {\n", " 'color': 'rgb(50, 171, 96)',\n", " 'width': 3,\n", " },\n", " },\n", " ]\n", "}\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='shapes-line-ref')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Creating Tangent Lines with Shapes" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 4, "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", "x0 = np.linspace(1, 3, 200)\n", "y0 = x0 * np.sin(np.power(x0, 2)) + 1\n", "\n", "trace0 = go.Scatter(\n", " x=x0,\n", " y=y0,\n", ")\n", "data = [trace0]\n", "layout = {\n", " 'title': \"$f(x)=x\\\\sin(x^2)+1\\\\\\\\ f\\'(x)=\\\\sin(x^2)+2x^2\\\\cos(x^2)$\",\n", " 'shapes': [\n", " {\n", " 'type': 'line',\n", " 'x0': 1,\n", " 'y0': 2.30756,\n", " 'x1': 1.75,\n", " 'y1': 2.30756,\n", " 'opacity': 0.7,\n", " 'line': {\n", " 'color': 'red',\n", " 'width': 2.5,\n", " },\n", " },\n", " {\n", " 'type': 'line',\n", " 'x0': 2.5,\n", " 'y0': 3.80796,\n", " 'x1': 3.05,\n", " 'y1': 3.80796,\n", " 'opacity': 0.7,\n", " 'line': {\n", " 'color': 'red',\n", " 'width': 2.5,\n", " },\n", " },\n", " {\n", " 'type': 'line',\n", " 'x0': 1.90,\n", " 'y0': -1.1827,\n", " 'x1': 2.50,\n", " 'y1': -1.1827,\n", " 'opacity': 0.7,\n", " 'line': {\n", " 'color': 'red',\n", " 'width': 2.5,\n", " },\n", " },\n", " ]\n", "}\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='tangent-line')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Rectangles Positioned Relative to the Axes" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "trace0 = go.Scatter(\n", " x=[1.5, 4.5],\n", " y=[0.75, 0.75],\n", " text=['Unfilled Rectangle', 'Filled Rectangle'],\n", " mode='text',\n", ")\n", "data = [trace0]\n", "layout = {\n", " 'xaxis': {\n", " 'range': [0, 7],\n", " 'showgrid': False,\n", " },\n", " 'yaxis': {\n", " 'range': [0, 3.5]\n", " },\n", " 'shapes': [\n", " # unfilled Rectangle\n", " {\n", " 'type': 'rect',\n", " 'x0': 1,\n", " 'y0': 1,\n", " 'x1': 2,\n", " 'y1': 3,\n", " 'line': {\n", " 'color': 'rgba(128, 0, 128, 1)',\n", " },\n", " },\n", " # filled Rectangle\n", " {\n", " 'type': 'rect',\n", " 'x0': 3,\n", " 'y0': 1,\n", " 'x1': 6,\n", " 'y1': 2,\n", " 'line': {\n", " 'color': 'rgba(128, 0, 128, 1)',\n", " 'width': 2,\n", " },\n", " 'fillcolor': 'rgba(128, 0, 128, 0.7)',\n", " },\n", " ]\n", "}\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='shapes-rectangle')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Rectangle Positioned Relative to the Plot & to the Axes" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "trace0 = go.Scatter(\n", " x=[1.5, 3],\n", " y=[2.5, 2.5],\n", " text=['Rectangle reference to the plot',\n", " 'Rectangle reference to the axes'],\n", " mode='text',\n", ")\n", "data = [trace0]\n", "layout = {\n", " 'xaxis': {\n", " 'range': [0, 4],\n", " 'showgrid': False,\n", " },\n", " 'yaxis': {\n", " 'range': [0, 4]\n", " },\n", " 'shapes': [\n", " # Rectangle reference to the axes\n", " {\n", " 'type': 'rect',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'x0': 2.5,\n", " 'y0': 0,\n", " 'x1': 3.5,\n", " 'y1': 2,\n", " 'line': {\n", " 'color': 'rgb(55, 128, 191)',\n", " 'width': 3,\n", " },\n", " 'fillcolor': 'rgba(55, 128, 191, 0.6)',\n", " },\n", " # Rectangle reference to the plot\n", " {\n", " 'type': 'rect',\n", " 'xref': 'paper',\n", " 'yref': 'paper',\n", " 'x0': 0.25,\n", " 'y0': 0,\n", " 'x1': 0.5,\n", " 'y1': 0.5,\n", " 'line': {\n", " 'color': 'rgb(50, 171, 96)',\n", " 'width': 3,\n", " },\n", " 'fillcolor': 'rgba(50, 171, 96, 0.6)',\n", " },\n", " ]\n", "}\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='shapes-rectangle-ref')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Highlighting Time Series Regions with Rectangle Shapes" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "trace0 = go.Scatter(\n", " x=['2015-02-01', '2015-02-02', '2015-02-03', '2015-02-04', '2015-02-05',\n", " '2015-02-06', '2015-02-07', '2015-02-08', '2015-02-09', '2015-02-10',\n", " '2015-02-11', '2015-02-12', '2015-02-13', '2015-02-14', '2015-02-15',\n", " '2015-02-16', '2015-02-17', '2015-02-18', '2015-02-19', '2015-02-20',\n", " '2015-02-21', '2015-02-22', '2015-02-23', '2015-02-24', '2015-02-25',\n", " '2015-02-26', '2015-02-27', '2015-02-28'],\n", " y=[-14, -17, -8, -4, -7, -10, -12, -14, -12, -7, -11, -7, -18, -14, -14,\n", " -16, -13, -7, -8, -14, -8, -3, -9, -9, -4, -13, -9, -6],\n", " mode='lines',\n", " name='temperature'\n", ")\n", "data = [trace0]\n", "layout = {\n", " # to highlight the timestamp we use shapes and create a rectangular\n", " 'shapes': [\n", " # 1st highlight during Feb 4 - Feb 6\n", " {\n", " 'type': 'rect',\n", " # x-reference is assigned to the x-values\n", " 'xref': 'x',\n", " # y-reference is assigned to the plot paper [0,1]\n", " 'yref': 'paper',\n", " 'x0': '2015-02-04',\n", " 'y0': 0,\n", " 'x1': '2015-02-06',\n", " 'y1': 1,\n", " 'fillcolor': '#d3d3d3',\n", " 'opacity': 0.2,\n", " 'line': {\n", " 'width': 0,\n", " }\n", " },\n", " # 2nd highlight during Feb 20 - Feb 23\n", " {\n", " 'type': 'rect',\n", " 'xref': 'x',\n", " 'yref': 'paper',\n", " 'x0': '2015-02-20',\n", " 'y0': 0,\n", " 'x1': '2015-02-22',\n", " 'y1': 1,\n", " 'fillcolor': '#d3d3d3',\n", " 'opacity': 0.2,\n", " 'line': {\n", " 'width': 0,\n", " }\n", " }\n", " ]\n", "}\n", "py.iplot({'data': data, 'layout': layout}, filename='timestamp-highlight')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Circles Positioned Relative to the Axes" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "trace0 = go.Scatter(\n", " x=[1.5, 3.5],\n", " y=[0.75, 2.5],\n", " text=['Unfilled Circle', \n", " 'Filled Circle'],\n", " mode='text',\n", ")\n", "data = [trace0]\n", "\n", "layout = {\n", " 'xaxis': {\n", " 'range': [0, 4.5],\n", " 'zeroline': False,\n", " },\n", " 'yaxis': {\n", " 'range': [0, 4.5]\n", " },\n", " 'width': 800,\n", " 'height': 800,\n", " 'shapes': [\n", " # unfilled circle\n", " {\n", " 'type': 'circle',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'x0': 1,\n", " 'y0': 1,\n", " 'x1': 3,\n", " 'y1': 3,\n", " 'line': {\n", " 'color': 'rgba(50, 171, 96, 1)',\n", " },\n", " },\n", " # filled circle\n", " {\n", " 'type': 'circle',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'fillcolor': 'rgba(50, 171, 96, 0.7)',\n", " 'x0': 3,\n", " 'y0': 3,\n", " 'x1': 4,\n", " 'y1': 4,\n", " 'line': {\n", " 'color': 'rgba(50, 171, 96, 1)',\n", " },\n", " },\n", " ]\n", "}\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='shapes-circle')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Highlighting Clusters of Scatter Points with Circle Shapes" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 9, "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", "x0 = np.random.normal(2, 0.45, 300)\n", "y0 = np.random.normal(2, 0.45, 300)\n", "\n", "x1 = np.random.normal(6, 0.4, 200)\n", "y1 = np.random.normal(6, 0.4, 200)\n", "\n", "x2 = np.random.normal(4, 0.3, 200)\n", "y2 = np.random.normal(4, 0.3, 200)\n", "\n", "trace0 = go.Scatter(\n", " x=x0,\n", " y=y0,\n", " mode='markers',\n", ")\n", "trace1 = go.Scatter(\n", " x=x1,\n", " y=y1,\n", " mode='markers'\n", ")\n", "trace2 = go.Scatter(\n", " x=x2,\n", " y=y2,\n", " mode='markers'\n", ")\n", "trace3 = go.Scatter(\n", " x=x1,\n", " y=y0,\n", " mode='markers'\n", ")\n", "layout = {\n", " 'shapes': [\n", " {\n", " 'type': 'circle',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'x0': min(x0),\n", " 'y0': min(y0),\n", " 'x1': max(x0),\n", " 'y1': max(y0),\n", " 'opacity': 0.2,\n", " 'fillcolor': 'blue',\n", " 'line': {\n", " 'color': 'blue',\n", " },\n", " },\n", " {\n", " 'type': 'circle',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'x0': min(x1),\n", " 'y0': min(y1),\n", " 'x1': max(x1),\n", " 'y1': max(y1),\n", " 'opacity': 0.2,\n", " 'fillcolor': 'orange',\n", " 'line': {\n", " 'color': 'orange',\n", " },\n", " },\n", " {\n", " 'type': 'circle',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'x0': min(x2),\n", " 'y0': min(y2),\n", " 'x1': max(x2),\n", " 'y1': max(y2),\n", " 'opacity': 0.2,\n", " 'fillcolor': 'green',\n", " 'line': {\n", " 'color': 'green',\n", " },\n", " },\n", " {\n", " 'type': 'circle',\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'x0': min(x1),\n", " 'y0': min(y0),\n", " 'x1': max(x1),\n", " 'y1': max(y0),\n", " 'opacity': 0.2,\n", " 'fillcolor': 'red',\n", " 'line': {\n", " 'color': 'red',\n", " },\n", " },\n", " ],\n", " 'showlegend': False,\n", "}\n", "data = [trace0, trace1, trace2, trace3]\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='clusters')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Venn Diagram with Circle Shapes" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "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", "trace0 = go.Scatter(\n", " x=[1, 1.75, 2.5],\n", " y=[1, 1, 1],\n", " text=['$A$', '$A+B$', '$B$'],\n", " mode='text',\n", " textfont=dict(\n", " color='black',\n", " size=18,\n", " family='Arail',\n", " )\n", ")\n", "\n", "data = [trace0]\n", "\n", "layout = {\n", " 'xaxis': {\n", " 'showticklabels': False,\n", " 'showgrid': False,\n", " 'zeroline': False,\n", " },\n", " 'yaxis': {\n", " 'showticklabels': False,\n", " 'showgrid': False,\n", " 'zeroline': False,\n", " },\n", " 'shapes': [\n", " {\n", " 'opacity': 0.3,\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'fillcolor': 'blue',\n", " 'x0': 0,\n", " 'y0': 0,\n", " 'x1': 2,\n", " 'y1': 2,\n", " 'type': 'circle',\n", " 'line': {\n", " 'color': 'blue',\n", " },\n", " },\n", " {\n", " 'opacity': 0.3,\n", " 'xref': 'x',\n", " 'yref': 'y',\n", " 'fillcolor': 'gray',\n", " 'x0': 1.5,\n", " 'y0': 0,\n", " 'x1': 3.5,\n", " 'y1': 2,\n", " 'type': 'circle',\n", " 'line': {\n", " 'color': 'gray',\n", " },\n", " }\n", " ],\n", " 'margin': {\n", " 'l': 20,\n", " 'r': 20,\n", " 'b': 100\n", " },\n", " 'height': 600,\n", " 'width': 800,\n", "}\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='venn-diagram')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### SVG Paths" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "trace0 = go.Scatter(\n", " x=[2, 1, 8, 8],\n", " y=[0.25, 9, 2, 6],\n", " text=['Filled Triangle',\n", " 'Filled Polygon',\n", " 'Quadratic Bezier Curves',\n", " 'Cubic Bezier Curves'],\n", " mode='text',\n", ")\n", "data = [trace0]\n", "layout = {\n", "\n", " 'xaxis': {\n", " 'range': [0, 9],\n", " 'zeroline': False,\n", " },\n", " 'yaxis': {\n", " 'range': [0, 11],\n", " 'showgrid': False,\n", " },\n", " 'shapes': [\n", " # Quadratic Bezier Curves\n", " {\n", " 'type': 'path',\n", " 'path': 'M 4,4 Q 6,0 8,4',\n", " 'line': {\n", " 'color': 'rgb(93, 164, 214)',\n", " },\n", " },\n", " # Cubic Bezier Curves\n", " {\n", " 'type': 'path',\n", " 'path': 'M 1,4 C 2,8 6,4 8,8',\n", " 'line': {\n", " 'color': 'rgb(207, 114, 255)',\n", " },\n", " },\n", " # filled Triangle\n", " {\n", " 'type': 'path',\n", " 'path': ' M 1 1 L 1 3 L 4 1 Z',\n", " 'fillcolor': 'rgba(44, 160, 101, 0.5)',\n", " 'line': {\n", " 'color': 'rgb(44, 160, 101)',\n", " },\n", " },\n", " # filled Polygon\n", " {\n", " 'type': 'path',\n", " 'path': ' M 3,7 L2,8 L2,9 L3,10, L4,10 L5,9 L5,8 L4,7 Z',\n", " 'fillcolor': 'rgba(255, 140, 184, 0.5)',\n", " 'line': {\n", " 'color': 'rgb(255, 140, 184)',\n", " },\n", " },\n", "\n", " ]\n", "}\n", "fig = {\n", " 'data': data,\n", " 'layout': layout,\n", "}\n", "py.iplot(fig, filename='shapes-path')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dash Example" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Dash](https://plotly.com/products/dash/) is an Open Source Python library which can help you convert plotly figures into a reactive, web-based application. Below is a simple example of a dashboard created using Dash. Its [source code](https://github.com/plotly/simple-example-chart-apps/tree/master/dash-shapesplot) can easily be deployed to a PaaS." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.display import IFrame\n", "IFrame(src= \"https://dash-simple-apps.plotly.host/dash-shapesplot/\", width=\"100%\", height=\"650px\", frameBorder=\"0\")\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.display import IFrame\n", "IFrame(src= \"https://dash-simple-apps.plotly.host/dash-shapesplot/code\", width=\"100%\", height=500, frameBorder=\"0\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Reference\n", "See https://plotly.com/python/reference/#layout-shapes for more information and chart attribute options!" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "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 /private/var/folders/s5/vjqn03zs7nn8zs_fwzcf14r40000gn/T/pip-req-build-0zyzncdb\n", "Building wheels for collected packages: publisher\n", " Building wheel for publisher (setup.py) ... \u001b[?25ldone\n", "\u001b[?25h Stored in directory: /private/var/folders/s5/vjqn03zs7nn8zs_fwzcf14r40000gn/T/pip-ephem-wheel-cache-ni1aug4o/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", "Successfully built publisher\n", "Installing collected packages: publisher\n", " Found existing installation: publisher 0.13\n", " Uninstalling publisher-0.13:\n", " Successfully uninstalled publisher-0.13\n", "Successfully installed publisher-0.13\n", "\u001b[33mYou are using pip version 19.0.3, however version 19.1.1 is available.\n", "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\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", "import publisher\n", "publisher.publish(\n", " 'shapes.ipynb', 'python/shapes/', 'Shapes | plotly',\n", " 'How to make SVG shapes in python. Examples of lines, circle, rectangle, and path.',\n", " title = 'Shapes | plotly',\n", " name = 'Shapes',\n", " thumbnail='thumbnail/shape.jpg', language='python',\n", " has_thumbnail='true', display_as='file_settings', order=32, \n", " ipynb='~notebook_demo/14')" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 1 }