This repository was archived by the owner on Dec 29, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdropdown.py
executable file
·76 lines (65 loc) · 2.09 KB
/
dropdown.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
"""https://plot.ly/python/dropdowns/"""
import plotly
import plotly.graph_objs as go
import numpy as np
fn = "data/volcano.csv"
def main():
dat = np.loadtxt(fn, delimiter=",", skiprows=1)
data = [go.Surface(z=dat)] # , colorscale='Viridis')]
layout = go.Layout(
width=800,
height=900,
autosize=False,
margin={"t": 0, "b": 0, "l": 0, "r": 0},
scene=dict(
xaxis=dict(
gridcolor="rgb(255, 255, 255)",
zerolinecolor="rgb(255, 255, 255)",
showbackground=True,
backgroundcolor="rgb(230, 230,230)",
),
yaxis=dict(
gridcolor="rgb(255, 255, 255)",
zerolinecolor="rgb(255, 255, 255)",
showbackground=True,
backgroundcolor="rgb(230, 230, 230)",
),
zaxis=dict(
gridcolor="rgb(255, 255, 255)",
zerolinecolor="rgb(255, 255, 255)",
showbackground=True,
backgroundcolor="rgb(230, 230,230)",
),
aspectratio=dict(x=1, y=1, z=0.7),
aspectmode="manual",
),
)
updatemenus = list(
[
dict(
buttons=list(
[
dict(args=["type", "surface"], label="3D Surface", method="restyle"),
dict(args=["type", "heatmap"], label="Heatmap", method="restyle"),
]
),
direction="down",
pad={"r": 10, "t": 10},
showactive=True,
x=0.1,
xanchor="left",
y=1.1,
yanchor="top",
)
]
)
annotations = list(
[dict(text="Trace type:", x=0, y=1.085, yref="paper", align="left", showarrow=False)]
)
layout["updatemenus"] = updatemenus
layout["annotations"] = annotations
fig = dict(data=data, layout=layout)
plotly.offline.plot(fig, filename="dropdown.html")
if __name__ == "__main__":
main()