plottingutils

Useful code snippets for making commonly used plots in Raphtory.

Functions

FunctionDescription
ccdfReturns x coordinates and y coordinates for a ccdf (complementary cumulative density function) from a list of observations.
cdfReturns x coordinates and y coordinates for a cdf (cumulative density function) from a list of observations.
global_motif_heatplotOut-of-the-box plotting of global motif counts corresponding to the layout in Motifs in Temporal Networks (Paranjape et al)
human_formatConverts a number over 1000 to a string with 1 d.p and the corresponding letter. e.g. with input 24134, 24.1k as a string would be returned. This is used in the motif plots to make annotated heatmap cells more concise.
lorenzReturns x coordinates and y coordinates for a Lorenz Curve from a list of observations.
ordinal_numberReturns ordinal number of integer input.
to_motif_matrixConverts a 40d vector of global motifs to a 2d grid of motifs corresponding to the layout in Motifs in Temporal Networks (Paranjape et al)

Function Details

ccdf

Signature: ccdf(observations, normalised=True)

Returns x coordinates and y coordinates for a ccdf (complementary cumulative density function) from a list of observations.

Parameters

NameTypeDefaultDescription
normalisedbool, optionalTrueDefaults to True. If true, y coordinates normalised such that y is the probability of finding a value greater than than or equal to x, if false y is the number of observations greater than or equal to x.
observationslist-list of observations, should be numeric

cdf

Signature: cdf(observations, normalised=True)

Returns x coordinates and y coordinates for a cdf (cumulative density function) from a list of observations.

Parameters

NameTypeDefaultDescription
normalisedbool, optionalTrueif true, y coordinates normalised such that y is the probability of finding a value less than or equal to x, if false y is the number of observations less than or equal to x. Defaults to True.
observationslist-list of observations, should be numeric

global_motif_heatplot

Signature: global_motif_heatplot(motifs, cmap='YlGnBu', kwargs=\{\})

Out-of-the-box plotting of global motif counts corresponding to the layout in Motifs in Temporal Networks (Paranjape et al)

Parameters

NameTypeDefaultDescription
cmapoptional'YlGnBu'
kwargsoptional\{\}
motifslist | np.ndarray-1 dimensional length-40 array of motifs, which should be the list of motifs returned from the global_temporal_three_node_motifs function in Raphtory. **kwargs: arguments to

Returns

TypeDescription
matplotlib.axes.Axesax item containing the heatmap with motif labels on the axes.

human_format

Signature: human_format(num)

Converts a number over 1000 to a string with 1 d.p and the corresponding letter. e.g. with input 24134, 24.1k as a string would be returned. This is used in the motif plots to make annotated heatmap cells more concise.

Parameters

NameTypeDefaultDescription
numint-number to be abbreviated

Returns

TypeDescription
strnumber in abbreviated string format.

lorenz

Signature: lorenz(observations)

Returns x coordinates and y coordinates for a Lorenz Curve from a list of observations.

Parameters

NameTypeDefaultDescription
observationslist-list of observations, should be numeric

ordinal_number

Signature: ordinal_number(number)

Returns ordinal number of integer input.

Parameters

NameTypeDefaultDescription
numberint-input number

Returns

TypeDescription
strordinal for that number as string

to_motif_matrix

Signature: to_motif_matrix(motifs, data_type=int)

Converts a 40d vector of global motifs to a 2d grid of motifs corresponding to the layout in Motifs in Temporal Networks (Paranjape et al)

Parameters

NameTypeDefaultDescription
data_typeoptionalint
motifslist | np.ndarray-1 dimensional length-40 array of motifs.

Returns

TypeDescription
np.ndarray6x6 array of motifs whose ijth element is M_ij in Motifs in Temporal Networks (Paranjape et al).