You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/webgl-vs-svg.md
+107-9Lines changed: 107 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ jupyter:
6
6
extension: .md
7
7
format_name: markdown
8
8
format_version: '1.3'
9
-
jupytext_version: 1.16.1
9
+
jupytext_version: 1.16.3
10
10
kernelspec:
11
11
display_name: Python 3 (ipykernel)
12
12
language: python
@@ -20,17 +20,17 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.10.11
23
+
version: 3.10.0
24
24
plotly:
25
-
description: Using WebGL for increased speed, improved interactivity, and the
26
-
ability to plot even more data!
25
+
description: Using WebGL and NumPy arrays for increased speed, improved interactivity,
26
+
and the ability to plot even more data!
27
27
display_as: basic
28
28
language: python
29
29
layout: base
30
-
name: WebGL vs SVG
30
+
name: High Performance Visualization
31
31
order: 14
32
-
permalink: python/webgl-vs-svg/
33
-
redirect_from: python/compare-webgl-svg/
32
+
permalink: python/performance/
33
+
redirect_from: python/webgl-vs-svg/
34
34
thumbnail: thumbnail/webgl.jpg
35
35
---
36
36
@@ -72,12 +72,12 @@ To use it, in the environment where your Plotly figures are being rendered, load
72
72
73
73
In a Jupyter notebook environment that supports magic commands, you can load it with the [HTML magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html#cellmagic-html):
See https://plotly.com/python/reference/scattergl/ for more information and chart attribute options!
201
+
202
+
## NumPy Arrays
203
+
204
+
*New in Plotly.py 6.0**
205
+
206
+
Improve the performance of generating Plotly figures that use a large number of data points by using NumPy arrays and other objects that can be converted to NumPy arrays, such as Pandas Series and Index objects.
207
+
208
+
Plotly.py uses Plotly.js for rendering, which supports base64-encoded typed arrays. In Plotly.py, NumPy array and NumPy-convertible arrays are base64 encoded before being passed to Plotly.js for rendering.
209
+
210
+
### Arrays and Data Types Supported
211
+
212
+
The following types of array objects in Python are supported:
213
+
214
+
- Numpy `numpy.ndarray` objects.
215
+
- Pandas Index, `pandas.Index`, or Series, `pandas.Series`, objects.
216
+
- Array objects that can be converted to `numpy.ndarray` objects. i.e., they implement `"__array__"` or `"__array_interface__"` and return a `numpy.ndarray`.
217
+
218
+
The following array data types are supported:
219
+
220
+
- int8
221
+
- uint8
222
+
- int16
223
+
- uint16
224
+
- int32
225
+
- uint32
226
+
- float32
227
+
- float64
228
+
- int64*
229
+
- uint64*
230
+
231
+
*If the array dtype is **int64** and **uint64**, often the default dtype for arrays in NumPy when no dtype is specified, those dtypes will be changed to other types internally by Plotly.py where possible.
232
+
233
+
### Unsupported Attributes
234
+
235
+
Arrays passed to attributes with the following names are not supported:
236
+
237
+
`geojson`, `layers`, and `range`.
238
+
239
+
240
+
### Example with NumPy Arrays
241
+
242
+
Here, we use NumPy arrays with a `go.Scatter3d` figure.
243
+
244
+
```python
245
+
import plotly.graph_objects as go
246
+
import numpy as np
247
+
248
+
np.random.seed(1)
249
+
250
+
# Number of data points
251
+
N =10000
252
+
253
+
# Generate random data
254
+
x = np.random.randn(N)
255
+
y = np.random.randn(N).astype('float32')
256
+
z = np.random.randint(size=N, low=0, high=256, dtype='uint8')
257
+
c = np.random.randint(size=N, low=-10, high=10, dtype='int8')
258
+
259
+
fig = go.Figure(data=[go.Scatter3d(
260
+
x=x,
261
+
y=y,
262
+
z=z,
263
+
marker=dict(color=c),
264
+
mode='markers',
265
+
opacity=0.2
266
+
)])
267
+
268
+
fig.show()
269
+
```
270
+
271
+
### Example with Multi-Dimensional Array
272
+
273
+
Here, we use a multi dimensional array with a `go.Surface` figure.
0 commit comments