-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxyz_coloring.py
More file actions
42 lines (33 loc) · 1.18 KB
/
Copy pathxyz_coloring.py
File metadata and controls
42 lines (33 loc) · 1.18 KB
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
"""Trying to recreate the 'repli_cube' mechanic"""
from itertools import product
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
coordinates_range = range(-2,3)
combinations = list(product(coordinates_range, repeat=3))
cols = list(zip(*combinations))
df = pd.DataFrame({"x":(cols[0]),
"y":(cols[1]),
"z":(cols[2]),
"value":(0*len(cols))},
dtype=int)
print(df)
# Create 3D visualization
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
# Color points by distance from origin
distances = np.sqrt(df['x']**2 + df['y']**2 + df['z']**2)
# Create scatter plot
scatter = ax.scatter(df['x'].values, df['y'].values, df['z'].values,
c=distances.values, cmap='viridis',
s=100, alpha=0.6, edgecolors='w', linewidth=0.5)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('3D Data Visualization\n(Colored by Distance from Origin)')
# Add colorbar
colorbar = plt.colorbar(scatter, ax=ax, pad=0.1, shrink=0.8)
colorbar.set_label('Distance from Origin')
plt.tight_layout()
plt.show()