@@ -33,77 +33,7 @@ jupyter:
33
33
thumbnail : thumbnail/b64.png
34
34
---
35
35
36
- ### Simple example showing how arrays of numbers could be passed as base64 typed array objects to plotly.js
37
-
38
- ``` python
39
- import plotly.graph_objects as go
40
-
41
- # x = [-200000 -100000 0 100000 200000]
42
- x = {' dtype' : ' int32' , ' bdata' : ' wPL8/2B5/v8AAAAAoIYBAEANAwA=' }
43
-
44
- # y = [0 1 2 3 4 5 6 7 8 9]
45
- y = {' dtype' : ' uint8' , ' bdata' : ' AAECAwQFBgcICQ==' }
46
-
47
- # z = [
48
- # [ 61 -295 -765 863 932]
49
- # [-897 96 724 791 -993]
50
- # [ -95 -796 -285 381 669]
51
- # [ 985 -153 425 -40 136]
52
- # [-856 955 -871 414 996]
53
- # [ 966 607 -154 -251 -882]
54
- # [-492 -116 414 426 305]
55
- # [ 919 202 -505 300 -833]
56
- # [ 278 -152 -643 -950 -86]
57
- # [ 898 -532 608 -93 110]]
58
- z = {
59
- ' dtype' : ' int16' ,
60
- ' bdata' : ' PQDZ/gP9XwOkA3/8YADUAhcDH/yh/+T84/59AZ0C2QNn/6kB2P+IAKj8uwOZ/J4B5APGA18CZv8F/478FP6M/54BqgExAZcDygAH/iwBv/wWAWj/ff1K/Kr/ggPs/WACo/9uAA==' , ' shape' : ' 10, 5'
61
- }
62
-
63
- fig = go.Figure(data = [go.Surface(
64
- x = x,
65
- y = y,
66
- z = z
67
- )])
68
-
69
- fig.show()
70
- ```
71
-
72
- ### Example where base64 is applied to pass values as typed array objects to plotly.js
73
-
74
- ``` python
75
- import plotly.graph_objects as go
76
- import numpy as np
77
- from base64 import b64encode
78
-
79
- def b64 (arr ) :
80
- return {
81
- ' dtype' : str (arr.dtype),
82
- ' bdata' : b64encode(arr).decode(' ascii' )
83
- }
84
-
85
- np.random.seed(1 )
86
-
87
- N = 10000
88
-
89
- x = np.random.randn(N)
90
- y = np.random.randn(N).astype(' float32' )
91
- z = np.random.randint(size = N, low = 0 , high = 256 , dtype = ' uint8' )
92
- c = np.random.randint(size = N, low = - 10 , high = 10 , dtype = ' int8' )
93
-
94
- fig = go.Figure(data = [go.Scatter3d(
95
- x = b64(x),
96
- y = b64(y),
97
- z = b64(z),
98
- marker = dict (color = b64(c)),
99
- mode = ' markers' ,
100
- opacity = 0.2
101
- )])
102
-
103
- fig.show()
104
- ```
105
-
106
- ### Similar example where base64 is automatically applied to pass numpy arrays to plotly.js
36
+ ### Example where base64 is automatically applied to pass numpy arrays to plotly.js
107
37
108
38
``` python
109
39
import plotly.graph_objects as go
@@ -130,40 +60,7 @@ fig = go.Figure(data=[go.Scatter3d(
130
60
fig.show()
131
61
```
132
62
133
-
134
- ### Example where base64 is applied to pass 2 dimensional values as typed array objects to plotly.js using shape in the spec
135
-
136
- ``` python
137
- import plotly.graph_objects as go
138
- import numpy as np
139
- from base64 import b64encode
140
-
141
- def b64 (arr ) :
142
- return {
143
- ' dtype' : str (arr.dtype),
144
- ' bdata' : b64encode(arr).decode(' ascii' ),
145
- ' shape' : None if arr.ndim == 1 else str (arr.shape)[1 :- 1 ]
146
- }
147
-
148
- np.random.seed(1 )
149
-
150
- M = 100
151
- N = 200
152
-
153
- x = np.arange(0 , M, 1 , ' int32' )
154
- y = np.arange(0 , N, 1 , ' uint8' )
155
- z = np.random.random([N, M])
156
-
157
- fig = go.Figure(data = [go.Surface(
158
- x = b64(x),
159
- y = b64(y),
160
- z = b64(z)
161
- )])
162
-
163
- fig.show()
164
- ```
165
-
166
- ### Similar example where base64 is automatically applied to pass multi-dimensional numpy arrays to plotly.js
63
+ ### Example where base64 is automatically applied to pass multi-dimensional numpy arrays to plotly.js
167
64
168
65
``` python
169
66
import plotly.graph_objects as go
@@ -188,11 +85,3 @@ fig = go.Figure(data=[go.Surface(
188
85
fig.show()
189
86
```
190
87
191
-
192
- ``` python
193
-
194
- ```
195
-
196
- ``` python
197
-
198
- ```
0 commit comments