-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy path01.Creative_3D_Scatter_Plot.py
51 lines (42 loc) · 1.15 KB
/
01.Creative_3D_Scatter_Plot.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
import numpy as np
import pandas as pd
import plotly.graph_objects as go
ys = 200 + np.random.randn(100)
x = [x for x in range(len(ys))]
plt.plot(x, ys, '-')
plt.fill_between(x, ys, 195, where=(ys > 195), facecolor='g', alpha=0.6)
plt.title("Sample Visualization")
plt.show()
def generate_random_data():
data = {
'X': np.random.randint(1, 100, 100),
'Y': np.random.randint(1, 100, 100),
'Z': np.random.randint(1, 100, 100),
'Value': 200 + np.random.randn(100)
}
return pd.DataFrame(data)
def visualize_3d_scatter(df):
fig = go.Figure(data=[go.Scatter3d(
x=df['X'],
y=df['Y'],
z=df['Z'],
mode='markers',
marker=dict(
size=6,
color=df['Value'],
colorscale='Viridis',
opacity=0.8
)
)])
fig.update_layout(
title='Creative 3D Scatter Plot',
scene=dict(xaxis_title='X', yaxis_title='Y', zaxis_title='Z'),
width=800, height=800,
showlegend=False
)
fig.show()
def main():
data_df = generate_random_data()
visualize_3d_scatter(data_df)
if __name__ == "__main__":
main()