Menu

Diagrams
Interactive
24 Python scripts generated for network diagram this week

Network Diagram

Chart overview

Network diagrams (graph visualizations) display nodes and the connections (edges) between them.

Key points

  • They reveal structure in relationship data, including clusters, central nodes, and isolated elements.
  • Modern implementations support interactive exploration of complex networks.

Example Visualization

Interactive network diagram showing social connections with community colors

Create This Chart Now

Generate publication-ready network diagrams with AI in seconds. No coding required – just describe your data and let AI do the work.

View example prompt
Example AI Prompt

"Create an interactive network diagram showing a 'Social Media Influence Network' with 30 nodes representing users. Generate realistic network data with 3-4 community clusters (influencers, content creators, casual users, brands). Size nodes by 'Follower Count' (100 to 1M range, use log scale). Color nodes by 'User Type': Influencers (gold), Creators (blue), Brands (green), Users (gray). Edge thickness represents interaction frequency. Use force-directed layout (spring layout) for organic clustering. Add hover tooltips showing username, followers, and post count. Highlight the top 5 most connected nodes. Include a legend and network statistics (nodes, edges, avg degree). Interactive: click to highlight ego network."

How to create this chart in 30 seconds

1

Upload Data

Drag & drop your Excel or CSV file. Plotivy securely processes it in your browser.

2

AI Generation

Our AI analyzes your data and generates the Network Diagram code automatically.

3

Customize & Export

Tweak the design with natural language, then export as high-res PNG, SVG or PDF.

Python Code Example

example.py
# === IMPORTS ===
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx

# === USER-EDITABLE PARAMETERS ===
title = "Social Media Influence Network"
figsize = (14, 10)

# === EXAMPLE DATASET ===
np.random.seed(42)

# Node data: (name, type, followers)
nodes_data = [
    # Mega Influencers
    ('MegaStar A', 'Mega Influencer', 5000000),
    ('MegaStar B', 'Mega Influencer', 3500000),
    # Macro Influencers
    ('Lifestyle Pro', 'Macro Influencer', 800000),
    ('Tech Guru', 'Macro Influencer', 650000),
    ('Fitness Coach', 'Macro Influencer', 550000),
    # Micro Influencers
    ('Food Blogger', 'Micro Influencer', 120000),
    ('Travel Vlogger', 'Micro Influencer', 95000),
    ('Beauty Tips', 'Micro Influencer', 88000),
    # Brands
    ('Nike', 'Brand', 400000),
    ('Apple', 'Brand', 600000),
    ('Sephora', 'Brand', 250000),
    # Nano Influencers
    ('Local Chef', 'Nano Influencer', 8000),
    ('Yoga Life', 'Nano Influencer', 12000),
    ('Gamer Dude', 'Nano Influencer', 15000),
]

# Edge data: (source, target, weight)
edges_data = [
    ('MegaStar A', 'Lifestyle Pro', 85),
    ('MegaStar A', 'Nike', 95),
    ('MegaStar A', 'Tech Guru', 70),
    ('MegaStar B', 'Fitness Coach', 80),
    ('MegaStar B', 'Apple', 90),
    ('MegaStar B', 'Sephora', 75),
    ('Lifestyle Pro', 'Food Blogger', 65),
    ('Lifestyle Pro', 'Travel Vlogger', 60),
    ('Tech Guru', 'Gamer Dude', 55),
    ('Fitness Coach', 'Yoga Life', 70),
    ('Nike', 'Fitness Coach', 85),
    ('Apple', 'Tech Guru', 80),
    ('Sephora', 'Beauty Tips', 75),
    ('Food Blogger', 'Local Chef', 50),
    ('Beauty Tips', 'Local Chef', 45),
    ('MegaStar A', 'MegaStar B', 60),
]

# Create graph
G = nx.Graph()
for name, node_type, followers in nodes_data:
    G.add_node(name, type=node_type, followers=followers)
for source, target, weight in edges_data:
    G.add_edge(source, target, weight=weight)

# Print summary
print("=== Social Media Network Analysis ===")
print(f"\nNodes: {G.number_of_nodes()}")
print(f"Edges: {G.number_of_edges()}")
print(f"\nTop 5 by Degree:")
degrees = dict(G.degree())
for node, deg in sorted(degrees.items(), key=lambda x: x[1], reverse=True)[:5]:
    print(f"  {node}: {deg} connections")

# === CREATE NETWORK DIAGRAM ===
fig, ax = plt.subplots(figsize=figsize, facecolor='white')
ax.set_facecolor('white')

# Use Kamada-Kawai layout for better spacing
pos = nx.kamada_kawai_layout(G)

# Color mapping by type
color_map = {
    'Mega Influencer': '#E53935',
    'Macro Influencer': '#1E88E5', 
    'Micro Influencer': '#43A047',
    'Brand': '#FB8C00',
    'Nano Influencer': '#8E24AA'
}

# Node colors and sizes
node_colors = [color_map[G.nodes[node]['type']] for node in G.nodes()]
node_sizes = [np.log10(G.nodes[node]['followers']) * 120 for node in G.nodes()]

# Draw edges - thin gray lines
edge_widths = [G.edges[edge]['weight'] / 40 for edge in G.edges()]
nx.draw_networkx_edges(G, pos, width=edge_widths, alpha=0.5, 
                       edge_color='#999999', ax=ax)

# Draw nodes - solid circles with white border
nx.draw_networkx_nodes(G, pos, node_color=node_colors, node_size=node_sizes, 
                       edgecolors='white', linewidths=2, ax=ax)

# Draw labels - positioned below nodes
label_pos = {node: (coords[0], coords[1] - 0.08) for node, coords in pos.items()}
nx.draw_networkx_labels(G, label_pos, font_size=9, font_weight='bold', 
                        font_color='#333333', ax=ax)

# Legend
from matplotlib.patches import Patch
legend_elements = [
    Patch(facecolor=color, label=label, edgecolor='white', linewidth=1.5)
    for label, color in color_map.items()
]
legend = ax.legend(handles=legend_elements, loc='upper left', 
                   frameon=True, facecolor='white', edgecolor='#CCCCCC',
                   fontsize=10, title='Node Type', title_fontsize=11)

# Title
ax.set_title(title, fontsize=20, fontweight='bold', color='#333333', pad=15)

# Clean layout
ax.axis('off')
ax.margins(0.15)

plt.tight_layout()
plt.savefig('chart.png', dpi=150, bbox_inches='tight', facecolor='white')
print("Saved: chart.png")
plt.show()
# END-OF-CODE

Opens the Analyze page with this code pre-loaded and ready to execute

Console Output

Output
=== Social Media Network Analysis ===

Nodes: 14
Edges: 16

Top 5 by Degree:
  MegaStar A: 4 connections
  MegaStar B: 4 connections
  Lifestyle Pro: 3 connections
  Tech Guru: 3 connections
  Fitness Coach: 3 connections
Saved: chart.png

Common Use Cases

  • 1Social network analysis
  • 2Citation networks
  • 3Infrastructure mapping
  • 4Knowledge graphs

Pro Tips

Size nodes by importance metrics

Color by community/cluster

Use force-directed layouts for organic arrangement

Free Cheat Sheet

Scientific Chart Selection Cheat Sheet

Not sure whether to use a Violin Plot, Box Plot, or Ridge Plot? Download our single-page reference mapping the most-used scientific chart types, exactly when to use them, and the core Matplotlib/Seaborn functions.

Comparison Charts
Distribution Charts
Time Series Data
Common Mistakes
No spam. Unsubscribe anytime.