Gridplot: 可视化多个图表

此示例展示了如何使用gridplot来可视化图形。

[1]:
import graspologic

import numpy as np
%matplotlib inline
/home/runner/.cache/pypoetry/virtualenvs/graspologic-pkHfzCJ8-py3.10/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

使用gridplot叠加两个稀疏图

使用加权随机块模型模拟更多图形

2块模型定义如下:

\begin{align*} P = \begin{bmatrix}0.25 & 0.05 \\ 0.05 & 0.25 \end{bmatrix} \end{align*}

我们生成两个加权的SBM,其中权重分别来自离散均匀分布(1, 10)和离散均匀分布(2, 5)。

[2]:
from graspologic.simulations import sbm

n_communities = [50, 50]
p = np.array([[0.25, 0.05], [0.05, 0.25]])
wt = np.random.randint
wtargs = dict(low=1, high=10)

np.random.seed(1)
A_unif1= sbm(n_communities, p, wt=wt, wtargs=wtargs)

wtargs = dict(low=2, high=5)
A_unif2= sbm(n_communities, p, wt=wt, wtargs=wtargs)

可视化两个图表

[3]:
from graspologic.plot import gridplot

X = [A_unif1, A_unif2]
labels = ["Uniform(1, 10)", "Uniform(2, 5)"]

f = gridplot(X=X,
             labels=labels,
             title='Two Weighted Stochastic Block Models',
             height=12,
             font_scale=1.5)
../../_images/tutorials_plotting_gridplot_5_0.png