【发布时间】:2020-07-30 08:35:30
【问题描述】:
这是与我的代码相似的代码
import networkx as nx
from matplotlib import pyplot as plt
%matplotlib notebook
import pandas as pd
data={"A":["T1","T2","tom","adi","matan","tali","pimpunzu","jack","arzu"],
"B":["end","end","T1","T1","T1","T2","T2","matan","matan"]}
df=pd.DataFrame.from_dict(data)
G = nx.from_pandas_edgelist(df,source='A',target='B', edge_attr=None, create_using=nx.DiGraph())
f, ax = plt.subplots(figsize=(10, 10))
nx.draw(G, with_labels=True, font_weight='bold', ax=ax)
例如,我喜欢绘制图表的一部分,我喜欢只绘制["T1","matan","jack","arzu"]
这就是我想要得到的
data={"A":["jack","arzu","matan"],
"B":["matan","matan","T1"]}
df=pd.DataFrame.from_dict(data)
G = nx.from_pandas_edgelist(df,source='A',target='B', edge_attr=None, create_using=nx.DiGraph())
f, ax = plt.subplots(figsize=(10, 10))
nx.draw(G, with_labels=True, font_weight='bold', ax=ax)
我可以列出我喜欢绘制的内容吗? 或者我可以写出我喜欢在它们之间绘制的节点吗?
【问题讨论】:
标签: python pandas matplotlib plot networkx