Interactive and static knowledge graph, ontology, embedding, and temporal visualization.
semantica.visualization renders knowledge graphs, ontologies, embedding spaces, and temporal data as interactive HTML or static images: without launching the full Explorer server:
KGVisualizer: interactive network with force, hierarchical, and circular layouts
EmbeddingVisualizer: 2D/3D UMAP or t-SNE projections with cluster labels
TemporalVisualizer: timeline views and graph evolution across snapshots
AnalyticsVisualizer: centrality scores, community structure, degree distribution charts
Requires plotly: pip install plotly. Some exporters also need matplotlib or graphviz.
from semantica.visualization import KGVisualizerviz = KGVisualizer(layout="force", color_scheme="default")# Interactive: opens in browser, supports hover and clickviz.visualize_network(graph, output="interactive")
2
Apply layout and color options
viz = KGVisualizer(layout="force", color_scheme="vibrant")viz.visualize_network( graph, output="html", file_path="graph.html", node_color_by="type", # color nodes by entity type attribute)
3
Export to static formats
# Static PNG: for reports and embedding in documentsviz.visualize_network(graph, output="png", file_path="graph.png")# Vector SVG: for publications and scalable diagramsviz.visualize_network(graph, output="svg", file_path="graph.svg")
plotly is required for all visualizers. Install before use: pip install plotly. All visualizer methods raise ProcessingError if Plotly is not installed.
from semantica.visualization import KGVisualizerviz = KGVisualizer(layout="force", color_scheme="default")# Interactive: opens in browserviz.visualize_network(graph, output="interactive")# Save as HTML fileviz.visualize_network(graph, output="html", file_path="graph.html")# Static PNGviz.visualize_network(graph, output="png", file_path="graph.png")# Community-colored graphviz.visualize_communities(graph, communities, file_path="communities.html")# Centrality-sized nodesviz.visualize_centrality(graph, centrality, centrality_type="degree")# Entity type distribution bar chartviz.visualize_entity_types(graph, output="interactive")# Relationship frequency heatmapviz.visualize_relationship_matrix(graph, output="interactive")
Use max_nodes for large graphs. Force-directed layouts become unreadable and slow above ~1,000 nodes. Filter to a subgraph before visualizing large graphs.
HTML output is always the best starting point. Interactive HTML lets you zoom, pan, and hover for details. Only export to PNG/SVG/PDF when embedding in a report.
For interactive dashboards, prefer Explorer.KGVisualizer.visualize_network() generates a self-contained HTML file. The Explorer CLI (semantica-explorer) gives a full live web app with search, filtering, path-finding, and REST API.
Layout options (layout=):
Layout
Description
Best For
force
Physics simulation: clusters emerge naturally
General graphs
hierarchical
Top-down tree layout
Taxonomies, org charts
circular
Nodes on a circle, edges as chords
Small dense graphs
Visualize class hierarchies and property relationships:
UMAP is faster than t-SNE at scale. For embedding spaces with >5,000 points, UMAP completes in seconds; t-SNE may take minutes. Both produce good cluster separation.
Visualize how a knowledge graph changes over time:
from semantica.visualization import TemporalVisualizerviz = TemporalVisualizer()# Timeline of entity/relationship changesviz.visualize_timeline(temporal_data, output="interactive")# Animated network evolution: one frame per time stepviz.visualize_network_evolution(temporal_kg, output="html", file_path="evolution.html")# Side-by-side snapshot comparison# snapshots: dict mapping timestamp strings to graph dictssnapshots = { "2023-01": graph_v1, "2024-01": graph_v2,}viz.visualize_snapshot_comparison(snapshots, output="html", file_path="diff.html")# Temporal patterns: pass a list of pattern dictsviz.visualize_temporal_patterns(patterns, output="html", file_path="patterns.html")# Metrics evolution over timeviz.visualize_metrics_evolution(metrics_history, timestamps, output="interactive")
Visualize graph analytics results: centrality, communities, and degree distribution:
from semantica.visualization import AnalyticsVisualizerviz = AnalyticsVisualizer()# Bar chart of top-N nodes by centrality measure# param is centrality_type= (not metric=) and top_n= (not top_k=)viz.visualize_centrality_rankings( centrality, centrality_type="pagerank", top_n=20, output="html", file_path="centrality.html",)# Community-colored network graphviz.visualize_community_structure(kg, communities, output="html", file_path="communities.html")# Degree distribution histogramviz.visualize_degree_distribution(kg, output="html", file_path="degree_dist.html")# Connectivity analysis (connected/disconnected, component sizes)viz.visualize_connectivity(connectivity, output="interactive")# Full metrics dashboard (nodes, edges, density, diameter)viz.visualize_metrics_dashboard(metrics, output="interactive")# Compare multiple centrality measures side-by-sideviz.visualize_centrality_comparison(centrality_results, top_n=10)
All visualizers accept a color_scheme= constructor parameter:
viz = KGVisualizer(color_scheme="vibrant")
Scheme
Description
Best For
default
Blue-grey palette
General use
vibrant
High-contrast, saturated colours
Presentations
pastel
Soft, muted tones
Light backgrounds
dark
Dark background with bright nodes
Dark-mode dashboards
light
White background, thin edges
Publications, print
colorblind
Okabe-Ito safe palette
Accessibility
Use color_scheme="colorblind" in publications and dashboards. The Okabe-Ito palette is readable for everyone, including the ~8% of readers who are red-green colorblind.