wiheto / teneto

Temporal Network Tools
GNU General Public License v3.0
85 stars 26 forks source link

Label node on temporalnetwork ploting #82

Closed balandongiv closed 2 years ago

balandongiv commented 2 years ago
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')
ax.scatter([0,0,0], [0,1,2], s=100, color='red', zorder=100)
plt.show()

May I know how to provide label on the plot. Currently, the node is assign as int. What if I have a label say

label=['a','b','c','d','e','f','g']

balandongiv commented 2 years ago

Simply

label=['a','b','c','d','e','f','g']
tnet = teneto.TemporalNetwork(from_array=g_arr,nodelabels=label,timelabels=['S1','S2','S3'])