Closed balandongiv closed 2 years ago
Assume we have a temporal network as below.
import numpy as np import teneto import matplotlib.pyplot as plt A1 = np.array ( [[0., 0., 0., 0., 0,0,0],[5., 0., 0., 0., 0,0,0],[1., 0., 0., 0., 0,0,0], [0., 1., 2., 0., 0,0,0],[0., 0., 0., 1., 0,0,0], [0., 0., 0., 1., 0,0,0], [0., 0., 0., 0., 1,1,0]] ) A2 = np.array ( [[0., 0., 0., 0., 0,0,0],[5., 0., 0., 0., 0,0,0], [1., 0., 0., 0., 0,0,0], [0., 1., 2., 0., 0,0,0], [0., 0., 0., 1., 0,0,0],[0., 0., 1., 1., 0,0,0], [0., 0., 0., 0., 1,1,0]] ) A3 = np.array ( [[0., 0., 0., 0., 0,0,0], [0., 0., 0., 0., 0,0,0],[0., 0., 0., 0., 0,0,0], [0., 1., 2., 0., 0,0,0],[0., 0., 0., 1., 0,0,0],[0., 0., 0., 1., 0,0,0], [0., 0., 0., 0., 1,1,0]] ) g_arr=np.array((A1, A2, A3, )).T tnet = teneto.TemporalNetwork(from_array=g_arr) ax = tnet.plot('slice_plot') plt.show()
and, assume, we obtain a communities which represented as below
communities = np.array([[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 0, 0], [1, 1, 0], [0, 0, 2], [0, 0, 2]])
May I know, how to plot these communities to get something as shown in the figure below?
In the figure above, let membership 0,1,2 labeled as blue, red and yellow, respectively
blue
red
yellow
one work around I can think of is, by manually adjust the node as
ax.scatter([0,0,0], [0,1,2], s=100, color='red', zorder=100) # along this line of idea
So it is either:
tnet.plot('slice_plot', **{'communities': communities})
or
teneto.plot.slice_plot(g_arr, ax, communities=communities)
And that should work for you
Thanks, this is really helpful
Assume we have a temporal network as below.
and, assume, we obtain a communities which represented as below
May I know, how to plot these communities to get something as shown in the figure below?
In the figure above, let membership 0,1,2 labeled as
blue
,red
andyellow
, respectivelyone work around I can think of is, by manually adjust the node as
ax.scatter([0,0,0], [0,1,2], s=100, color='red', zorder=100) # along this line of idea