Now in Ploty you can implement WebGL with Scattergl()
in place of Scatter()
for increased speed, improved interactivity, and the ability to plot even more data!
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
N = 75000
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]
layout = dict(title = 'WEBGL')
fig = dict(data=data, layout=layout)
py.iplot(data, filename='webgl75')
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
N = 75000
trace = go.Scatter(
x = np.random.randn(N),
y = np.random.randn(N),
mode = 'markers',
marker = dict(
line = dict(
width = 1,
color = '#404040')
)
)
data = [trace]
layout = dict(title = 'SVG')
fig = dict(data=data, layout=layout)
py.iplot(fig, filename='svg75')
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/plotly/plotly/plotly.py:236: UserWarning: Woah there! Look at all those points! Due to browser limitations, the Plotly SVG drawing functions have a hard time graphing more than 500k data points for line charts, or 40k points for other types of charts. Here are some suggestions: (1) Use the `plotly.graph_objs.Scattergl` trace object to generate a WebGl graph. (2) Trying using the image API to return an image instead of a graph URL (3) Use matplotlib (4) See if you can create your visualization with fewer data points If the visualization you're using aggregates points (e.g., box plot, histogram, etc.) you can disregard this warning. /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/plotly/plotly/plotly.py:1441: UserWarning: Estimated Draw Time Too Long
The draw time for this plot will be slow for all clients.
For more information see
Scattergl()
: https://plotly.com/python/reference/#scattergl
Scatter()
: https://plotly.com/python/reference/#scatter
from IPython.display import display, HTML
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" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))
! pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
'comparewebgl.ipynb', 'python/compare-webgl-svg/', 'Python Comparing WebGL vs SVG | plotly',
'Comparing WebGL with Scattergl() to SVG with Scatter() in Python with Plotly.',
title = 'Comparing WebGL vs SVG | plotly',
name = 'Comparing WebGL vs SVG',
language='python')
Collecting git+https://github.com/plotly/publisher.git
Cloning https://github.com/plotly/publisher.git to /var/folders/72/g6h98xwx0h1gp4kc8rzhsdh80000gn/T/pip-1gqcFV-build
Installing collected packages: publisher
Found existing installation: publisher 0.10
Uninstalling publisher-0.10:
Successfully uninstalled publisher-0.10
Running setup.py install for publisher ... - done
Successfully installed publisher-0.10
You are using pip version 8.0.3, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.