forked from deephaven/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_figures.py
46 lines (40 loc) · 1.16 KB
/
common_figures.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
from deephaven import empty_table
from deephaven.plot.figure import Figure
import math
simple_plot = (
Figure()
.plot_xy(
series_name="Test",
t=empty_table(100).update(["x=i", "y=Math.sin(i)", "z=Math.cos(i)"]),
x="x",
y="y",
)
.show()
)
math_funcs = ["sin", "cos"]
shapes = [
"SQUARE",
"CIRCLE",
"UP_TRIANGLE",
"DOWN_TRIANGLE",
"RIGHT_TRIANGLE",
"LEFT_TRIANGLE",
"DIAMOND",
]
# Unsupported shapes: ["ELLIPSE", "HORIZONTAL_RECTANGLE", "VERTICAL_RECTANGLE"]
# Create a generic table that has enough columns to display all the shapes
# Re-uses some of the funcs
trig_table = empty_table(50).update(["x=i*0.1"])
for i in range(len(shapes)):
trig_table = trig_table.update(
[
f"y{i}=Math.{math_funcs[i % len(math_funcs)]}(x+{math.floor(i / len(math_funcs))})"
]
)
# Generate the table and figure based on the shapes created
trig_figure = Figure()
for i in range(len(shapes)):
trig_figure = trig_figure.plot_xy(
series_name=shapes[i], t=trig_table, x="x", y=f"y{i}"
).point(shape=shapes[i], size=len(shapes) - i, visible=True)
trig_figure = trig_figure.show()