|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "#### New to Plotly?\n", |
| 8 | + "Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).\n", |
| 9 | + "<br>You can set up Plotly to work in [online](https://plot.ly/python/getting-started/#initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/#start-plotting-online).\n", |
| 10 | + "<br>We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "markdown", |
| 15 | + "metadata": {}, |
| 16 | + "source": [ |
| 17 | + "#### Version Check\n", |
| 18 | + "Plotly's python package is updated frequently. Run `pip install plotly --upgrade` to use the latest version." |
| 19 | + ] |
| 20 | + }, |
| 21 | + { |
| 22 | + "cell_type": "code", |
| 23 | + "execution_count": 1, |
| 24 | + "metadata": {}, |
| 25 | + "outputs": [ |
| 26 | + { |
| 27 | + "data": { |
| 28 | + "text/plain": [ |
| 29 | + "'3.1.1'" |
| 30 | + ] |
| 31 | + }, |
| 32 | + "execution_count": 1, |
| 33 | + "metadata": {}, |
| 34 | + "output_type": "execute_result" |
| 35 | + } |
| 36 | + ], |
| 37 | + "source": [ |
| 38 | + "import plotly\n", |
| 39 | + "plotly.__version__" |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + "cell_type": "markdown", |
| 44 | + "metadata": {}, |
| 45 | + "source": [ |
| 46 | + "#### Set Default Trace Colors with `colorway`" |
| 47 | + ] |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "code", |
| 51 | + "execution_count": 2, |
| 52 | + "metadata": {}, |
| 53 | + "outputs": [ |
| 54 | + { |
| 55 | + "data": { |
| 56 | + "text/html": [ |
| 57 | + "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2807.embed\" height=\"525px\" width=\"100%\"></iframe>" |
| 58 | + ], |
| 59 | + "text/plain": [ |
| 60 | + "<plotly.tools.PlotlyDisplay object>" |
| 61 | + ] |
| 62 | + }, |
| 63 | + "execution_count": 2, |
| 64 | + "metadata": {}, |
| 65 | + "output_type": "execute_result" |
| 66 | + } |
| 67 | + ], |
| 68 | + "source": [ |
| 69 | + "import plotly.plotly as py\n", |
| 70 | + "import plotly.graph_objs as go\n", |
| 71 | + "\n", |
| 72 | + "import numpy as np\n", |
| 73 | + "\n", |
| 74 | + "\n", |
| 75 | + "def parabola_gen(a, b):\n", |
| 76 | + " return lambda x: a * x ** 2 + b\n", |
| 77 | + "\n", |
| 78 | + "\n", |
| 79 | + "parabolas = [parabola_gen(a, b) for a, b in zip(np.linspace(1, 3, 7), np.linspace(2, 14, 7))]\n", |
| 80 | + "x = np.linspace(-1, 3)\n", |
| 81 | + "data = [go.Scatter(x=x, y=p(x), mode='lines') for p in parabolas]\n", |
| 82 | + "\n", |
| 83 | + "colorway = ['#f3cec9', '#e7a4b6', '#cd7eaf', '#a262a9', '#6f4d96', '#3d3b72', '#182844']\n", |
| 84 | + "layout = go.Layout(colorway=colorway)\n", |
| 85 | + "\n", |
| 86 | + "py.iplot(go.Figure(data=data, layout=layout))\n" |
| 87 | + ] |
| 88 | + }, |
| 89 | + { |
| 90 | + "cell_type": "markdown", |
| 91 | + "metadata": {}, |
| 92 | + "source": [ |
| 93 | + "### Reference" |
| 94 | + ] |
| 95 | + }, |
| 96 | + { |
| 97 | + "cell_type": "markdown", |
| 98 | + "metadata": {}, |
| 99 | + "source": [ |
| 100 | + "See https://plot.ly/python/reference/ for more information and chart attribute options!" |
| 101 | + ] |
| 102 | + }, |
| 103 | + { |
| 104 | + "cell_type": "code", |
| 105 | + "execution_count": 3, |
| 106 | + "metadata": {}, |
| 107 | + "outputs": [ |
| 108 | + { |
| 109 | + "data": { |
| 110 | + "text/html": [ |
| 111 | + "<link href=\"//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700\" rel=\"stylesheet\" type=\"text/css\" />" |
| 112 | + ], |
| 113 | + "text/plain": [ |
| 114 | + "<IPython.core.display.HTML object>" |
| 115 | + ] |
| 116 | + }, |
| 117 | + "metadata": {}, |
| 118 | + "output_type": "display_data" |
| 119 | + }, |
| 120 | + { |
| 121 | + "data": { |
| 122 | + "text/html": [ |
| 123 | + "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">" |
| 124 | + ], |
| 125 | + "text/plain": [ |
| 126 | + "<IPython.core.display.HTML object>" |
| 127 | + ] |
| 128 | + }, |
| 129 | + "metadata": {}, |
| 130 | + "output_type": "display_data" |
| 131 | + }, |
| 132 | + { |
| 133 | + "name": "stdout", |
| 134 | + "output_type": "stream", |
| 135 | + "text": [ |
| 136 | + "Collecting git+https://github.com/plotly/publisher.git\n", |
| 137 | + " Cloning https://github.com/plotly/publisher.git to /tmp/pip-req-build-sMJsCC\n", |
| 138 | + "Building wheels for collected packages: publisher\n", |
| 139 | + " Running setup.py bdist_wheel for publisher ... \u001b[?25ldone\n", |
| 140 | + "\u001b[?25h Stored in directory: /tmp/pip-ephem-wheel-cache-msTCdJ/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", |
| 141 | + "Successfully built publisher\n", |
| 142 | + "Installing collected packages: publisher\n", |
| 143 | + " Found existing installation: publisher 0.11\n", |
| 144 | + " Uninstalling publisher-0.11:\n", |
| 145 | + " Successfully uninstalled publisher-0.11\n", |
| 146 | + "Successfully installed publisher-0.11\n", |
| 147 | + "\u001b[33mYou are using pip version 10.0.1, however version 18.0 is available.\n", |
| 148 | + "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n" |
| 149 | + ] |
| 150 | + } |
| 151 | + ], |
| 152 | + "source": [ |
| 153 | + "from IPython.display import display, HTML\n", |
| 154 | + "\n", |
| 155 | + "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\" />'))\n", |
| 156 | + "display(HTML('<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">'))\n", |
| 157 | + "\n", |
| 158 | + "! pip install git+https://github.com/plotly/publisher.git --upgrade\n", |
| 159 | + "import publisher\n", |
| 160 | + "publisher.publish(\n", |
| 161 | + " 'colorway.ipynb', 'python/colorway/', 'Colorway',\n", |
| 162 | + " 'How to set default trace colors with colorway.',\n", |
| 163 | + " title = 'Colorway in Python | Plotly',\n", |
| 164 | + " has_thumbnail='true', thumbnail='thumbnail/colorway.jpg', \n", |
| 165 | + " language='python', \n", |
| 166 | + " page_type='example_index',\n", |
| 167 | + " display_as='style_opt', \n", |
| 168 | + " order=7.9,\n", |
| 169 | + " ipynb= '~notebook_demo/256')" |
| 170 | + ] |
| 171 | + }, |
| 172 | + { |
| 173 | + "cell_type": "code", |
| 174 | + "execution_count": null, |
| 175 | + "metadata": {}, |
| 176 | + "outputs": [], |
| 177 | + "source": [] |
| 178 | + } |
| 179 | + ], |
| 180 | + "metadata": { |
| 181 | + "kernelspec": { |
| 182 | + "display_name": "Python 2", |
| 183 | + "language": "python", |
| 184 | + "name": "python2" |
| 185 | + }, |
| 186 | + "language_info": { |
| 187 | + "codemirror_mode": { |
| 188 | + "name": "ipython", |
| 189 | + "version": 2 |
| 190 | + }, |
| 191 | + "file_extension": ".py", |
| 192 | + "mimetype": "text/x-python", |
| 193 | + "name": "python", |
| 194 | + "nbconvert_exporter": "python", |
| 195 | + "pygments_lexer": "ipython2", |
| 196 | + "version": "2.7.15rc1" |
| 197 | + } |
| 198 | + }, |
| 199 | + "nbformat": 4, |
| 200 | + "nbformat_minor": 2 |
| 201 | +} |
0 commit comments