3D Scatter
Social Network Community Detection
Social network visualization showing community structure with neon color-coded clusters.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(123)
# Social network node positions
n_nodes = 150
# Create community structure
communities = 4
colors_community = ['#27D3F5', '#F5276C', '#6CF527', '#F5B027']
all_x, all_y, all_z, all_c, all_s = [], [], [], [], []
for i in range(communities):
n = n_nodes // communities
angle = i * 2 * np.pi / communities
cx, cy = 3 * np.cos(angle), 3 * np.sin(angle)
x = np.random.normal(cx, 0.8, n)
y = np.random.normal(cy, 0.8, n)
z = np.random.normal(0, 0.5, n)
# Node importance (degree)
importance = np.random.exponential(30, n) + 20
all_x.extend(x)
all_y.extend(y)
all_z.extend(z)
all_c.extend([colors_community[i]] * n)
all_s.extend(importance)
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
ax.scatter(all_x, all_y, all_z, c=all_c, s=all_s, alpha=0.7,
edgecolors='#374151', linewidths=0.3)
ax.set_xlabel('Dimension 1', color='#1f2937', fontsize=10)
ax.set_ylabel('Dimension 2', color='#1f2937', fontsize=10)
ax.set_zlabel('Dimension 3', color='#1f2937', fontsize=10)
ax.set_title('Social Network Community Detection', color='#1f2937', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.view_init(elev=25, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕