wiheto/teneto

Inconsistency when plotting slice plot a temporal network

Closed this issue · 6 comments

When ploting a temporal network using .plot, I notice neighboring interaction were not properly connected.

Below are the plot produced by teneto plot
ori_gtheory

The red line indicate where connection should exist. Specifically, at slice 2,3,4
file_gtheor

This issue can be replicate with the code below.

For reproducibility, the connection array can be download via:
link to array


import teneto
import matplotlib.pyplot as plt
g_arr=np.load('g_arr.npy')
plt.style.use('mpl20')
tnet = teneto.TemporalNetwork(from_array=g_arr)
ax = tnet.plot('slice_plot')
ax.scatter([0,0,0], [0,1,2], s=150, color='red', zorder=50)
plt.show()

Hi!

They are actually there but are being masked by the nodes.

teneto.plot.slice_plot(g_arr, nodesize=10)

Sorry about his. Will try and make some improvement so this doesn't happen again by accident (e.g. by autoscaling nodesize).

This is the resulting image I get

Figure_4

Thanks for prompt reply.

May I know you plot this graph?

I Tried
teneto.plot.slice_plot(g_arr, nodesize=10)

But, the compiler return an error

TypeError: slice_plot() missing 1 required positional argument: 'ax'

Amend the code to

teneto.plot.slice_plot(g_arr, nodesize=10,ax=ax)

Return an error of

AxesSubplot:xlabel='Time'

Wheras, amending the code as below

import teneto
import matplotlib.pyplot as plt
# g_arr=np.load('g_arr.npy')
plt.style.use('mpl20')
tnet = teneto.TemporalNetwork(from_array=g_arr)
ax = tnet.plot('slice_plot',nodesize=10)
ax.scatter([0,0,0], [0,1,2], s=150, color='red', zorder=50)
plt.show()

produced inconsistent node size (refer slice no 1) as below

amend_gt

Sorry, should have copy pasted what I did instead of just writing the code (incorrectly). This is what works for me

import numpy as np
import teneto
import matplotlib.pyplot as plt
fig,ax = plt.subplots(1)
g_arr=np.load('g_arr.npy')
teneto.plot.slice_plot(g_arr, ax, nodesize=10)
fig.show()
 

To fix your figure that you wrote above, you need to change:

ax.scatter([0,0,0], [0,1,2], s=150, color='red', zorder=50)

and change the size of the red scatter plots you are adding in manually

Thanks for the update @wiheto , really appreciate it