I am using igraph to analyze a network and find a specific kind of triad as subgraphs of the main network. I successfully did that but now I'm trying to plot these subgraphs in a multipanel figure using matplotlib.
import pandas as pd
import igraph as ig
import matplotlib.pyplot as plt
import math
# some long hidden code here to generate the main network (g)
# the triad pattern
ffl = g.Isoclass(n=3, cls=7, directed=True)
# finding the subgraphs
sub = g.get_subisomorphisms_vf2(ffl)
# trying to plot the subgraphs
ffls = []
for i in range(len(sub)):
vtx = g.vs.select(sub[i])
ffl = g.subgraph(vtx)
ffl.vs['name'] = g.vs[sub[i]]['name']
ffls.append(ffl)
visual_style = {'layout': 'reingold_tilford',
'vertex_label_size': 15}
fig, axs = plt.subplots(nrows=7, ncols=4, figsize=(15,25))
plt.subplots_adjust(wspace=0.5, hspace=0.5)
axs = axs.ravel()
for ax in axs:
ax.set_axis_off()
for ffl, ax in zip(ffls, axs):
ig.plot(ffl, target=ax, vertex_label=ffl.vs['name'], **visual_style)
plt.show()
The resulting figure shows all the subgraphs as intended but without the colors of the edges (that I already defined in the main network). I know the colors are being captured in the subgraphs because when I plot them individually the colors are there (also the attributes are correctly assigned to the edges). Only when I try to plot them all together that I have this "problem".
What I am doing wrong? It is possible to show the edge colors when using plt.subplots()? Can someone help me?
