#!/usr/bin/env python # coding: utf-8 # #### New to Plotly? # 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/). #
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). #
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!! # #### Compare WebGL and SVG # Checkout [this notebook](https://plotly.com/python/compare-webgl-svg) to compare WebGL and SVG scatter plots with 75,000 random data points # #### WebGL with 100,000 points # In[1]: import plotly.plotly as py import plotly.graph_objs as go import numpy as np N = 100000 trace = go.Scattergl( x = np.random.randn(N), y = np.random.randn(N), mode = 'markers', marker = dict( line = dict( width = 1, color = '#404040') ) ) data = [trace] py.iplot(data, filename='WebGL100000') # #### WebGL with 1 Million Points # In[2]: import plotly.plotly as py import plotly.graph_objs as go import numpy as np N = 1000000 trace = go.Scattergl( x = np.random.randn(N), y = np.random.randn(N), mode = 'markers', marker = dict( color = 'rgb(152, 0, 0)', line = dict( width = 1, color = 'rgb(0,0,0)') ) ) data = [trace] py.iplot(data, filename='WebGLmillion') # #### WebGL with many traces # In[3]: import plotly.plotly as py import plotly.graph_objs as go import numpy as np data = [] trace_num = 10 point_num = 5000 for i in range(trace_num): data.append(go.Scattergl( x = np.linspace(0, 1, point_num), y = np.random.randn(point_num)+(i*5) ) ) layout = dict(showlegend=False) fig=dict(data=data, layout=layout) py.iplot(fig, filename='WebGL_line') # ### Reference # See https://plotly.com/python/reference/#scattergl for more information and chart attribute options! # In[1]: from IPython.display import display, HTML display(HTML('')) display(HTML('')) get_ipython().system(' pip install git+https://github.com/plotly/publisher.git --upgrade') import publisher publisher.publish( 'webgl.ipynb', 'python/webgl-vs-svg/', 'Python WebGL vs SVG | plotly', 'Implement WebGL for increased speed, improved interactivity, and the ability to plot even more data!', title = 'Python WebGL vs SVG | plotly', name = 'WebGL vs SVG', has_thumbnail='true', thumbnail='thumbnail/webgl.jpg', language='python', display_as='basic', order=0.5, ipynb= '~notebook_demo/44') # In[ ]: