-
Notifications
You must be signed in to change notification settings - Fork 654
Expand file tree
/
Copy path3d.py
More file actions
36 lines (25 loc) · 852 Bytes
/
3d.py
File metadata and controls
36 lines (25 loc) · 852 Bytes
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
import logging
import flet_charts
import matplotlib.pyplot as plt
import numpy as np
import flet as ft
logging.basicConfig(level=logging.INFO)
def main(page: ft.Page):
plt.style.use("_mpl-gallery")
# Make data for a double helix
n = 50
theta = np.linspace(0, 2 * np.pi, n)
x1 = np.cos(theta)
y1 = np.sin(theta)
z1 = np.linspace(0, 1, n)
x2 = np.cos(theta + np.pi)
y2 = np.sin(theta + np.pi)
z2 = z1
# Plot with defined figure size
fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize=(8, 6))
ax.fill_between(x1, y1, z1, x2, y2, z2, alpha=0.5)
ax.plot(x1, y1, z1, linewidth=2, color="C0")
ax.plot(x2, y2, z2, linewidth=2, color="C0")
ax.set(xticklabels=[], yticklabels=[], zticklabels=[])
page.add(flet_charts.MatplotlibChartWithToolbar(figure=fig))
ft.run(main)