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/b64.md
+52-5Lines changed: 52 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -32,16 +32,59 @@ jupyter:
32
32
thumbnail: thumbnail/b64.png
33
33
---
34
34
35
-
### Example where base64 is automatically applied to pass numpy arrays to plotly.js
35
+
*New in Plotly.py 6.0**
36
+
37
+
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.
38
+
39
+
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.
40
+
41
+
42
+
## Arrays and Data Types Supported
43
+
44
+
The following types of array objects in Python are supported:
45
+
46
+
- Numpy `numpy.ndarray` objects.
47
+
- Pandas Index, `pandas.Index`, or Series, `pandas.Series`, objects.
48
+
- Array objects that can be converted to `numpy.ndarray` objects. i.e., they implement `"__array__"` or `"__array_interface__"` and return a `numpy.ndarray.
49
+
50
+
The following array data types are supported:
51
+
52
+
- int8
53
+
- uint8
54
+
- int16
55
+
- uint16
56
+
- int32
57
+
- uint32
58
+
- float32
59
+
- float64
60
+
- int64*
61
+
- uint64*
62
+
63
+
*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.
64
+
65
+
66
+
67
+
## Unsupported Attributes
68
+
69
+
Arrays passsed to attributes with the following names do not use the Plotly.js base64 typed arrays functionality:
70
+
71
+
`geojson`, `layers`, and `range`.
72
+
73
+
74
+
## Example with NumPy Arrays
75
+
76
+
Here, we use NumPy arrays with a `go.Scatter3d` figure.
36
77
37
78
```python
38
79
import plotly.graph_objects as go
39
80
import numpy as np
40
81
41
82
np.random.seed(1)
42
83
84
+
# Number of data points
43
85
N =10000
44
86
87
+
# Generate random data
45
88
x = np.random.randn(N)
46
89
y = np.random.randn(N).astype('float32')
47
90
z = np.random.randint(size=N, low=0, high=256, dtype='uint8')
0 commit comments