{ "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": [ "#### Compare WebGL and SVG\n", "Checkout [this notebook](https://plotly.com/python/compare-webgl-svg) to compare WebGL and SVG scatter plots with 75,000 random data points" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "#### WebGL with 100,000 points" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "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", "import numpy as np\n", "\n", "N = 100000\n", "trace = go.Scattergl(\n", " x = np.random.randn(N),\n", " y = np.random.randn(N),\n", " mode = 'markers',\n", " marker = dict(\n", " line = dict(\n", " width = 1, \n", " color = '#404040')\n", " )\n", ")\n", "data = [trace]\n", "py.iplot(data, filename='WebGL100000')" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "#### WebGL with 1 Million Points" ] }, { "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", "N = 1000000\n", "trace = go.Scattergl(\n", " x = np.random.randn(N),\n", " y = np.random.randn(N),\n", " mode = 'markers',\n", " marker = dict(\n", " color = 'rgb(152, 0, 0)',\n", " line = dict(\n", " width = 1,\n", " color = 'rgb(0,0,0)')\n", " )\n", ")\n", "data = [trace]\n", "py.iplot(data, filename='WebGLmillion')" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "#### WebGL with many traces" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "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", "import numpy as np\n", "\n", "data = []\n", "trace_num = 10\n", "point_num = 5000\n", "for i in range(trace_num):\n", " data.append(go.Scattergl(\n", " x = np.linspace(0, 1, point_num),\n", " y = np.random.randn(point_num)+(i*5)\n", " )\n", ")\n", "layout = dict(showlegend=False)\n", "fig=dict(data=data, layout=layout)\n", "py.iplot(fig, filename='WebGL_line')" ] }, { "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/#scattergl for more information and chart attribute options!" ] }, { "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": "stderr", "output_type": "stream", "text": [ "/usr/local/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", "/usr/local/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", "import publisher\n", "publisher.publish(\n", " 'webgl.ipynb', 'python/webgl-vs-svg/', 'Python WebGL vs SVG | plotly',\n", " 'Implement WebGL for increased speed, improved interactivity, and the ability to plot even more data!',\n", " title = 'Python WebGL vs SVG | plotly',\n", " name = 'WebGL vs SVG',\n", " has_thumbnail='true', thumbnail='thumbnail/webgl.jpg', \n", " language='python', \n", " display_as='basic', order=0.5,\n", " ipynb= '~notebook_demo/44')" ] }, { "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 }