Wie konvertiere ich ein 2D-Netzwerkx-Diagramm in interaktives 3D in Python?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie konvertiere ich ein 2D-Netzwerkx-Diagramm in interaktives 3D in Python?

by Guest » 17 Jan 2025, 07:00

Ich habe bereits ein 2D-Netzwerkdiagramm mit networkx in Python erstellt.
Code zum Erstellen von:

Code: Select all

import pandas as pd
import matplotlib as mpl

links_data = pd.read_csv("https://raw.githubusercontent.com/johnsnow09/network_graph/refs/heads/main/links_filtered.csv")

G = nx.from_pandas_edgelist(links_data, 'var1', 'var2')

cmap = mpl.colormaps['Set3'].colors # this has 12 colors for 11 categories

cat_colors = dict(zip(links_data['Category'].unique(), cmap))

colors = (links_data
.drop_duplicates('var1').set_index('var1')['Category']
.map(cat_colors)
.reindex(G.nodes)
)

nx.draw(G, with_labels=True, node_color=colors, node_size=200,
edge_color='black', linewidths=.5, font_size=2.5)
Es gibt das folgende Bild als Ausgabe
Image

Wie kann ich es in ein 3D-Diagramm umwandeln, damit ich die Netzwerkbeziehungen im Diagramm besser sehen kann?
Sehr dankbar Hilfe!

Top