plottingutils
Useful code snippets for making commonly used plots in Raphtory.
Functions
| Function | Description |
|---|---|
ccdf | Returns x coordinates and y coordinates for a ccdf (complementary cumulative density function) from a list of observations. |
cdf | Returns x coordinates and y coordinates for a cdf (cumulative density function) from a list of observations. |
global_motif_heatplot | Out-of-the-box plotting of global motif counts corresponding to the layout in Motifs in Temporal Networks (Paranjape et al) |
human_format | 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. |
lorenz | Returns x coordinates and y coordinates for a Lorenz Curve from a list of observations. |
ordinal_number | Returns ordinal number of integer input. |
to_motif_matrix | 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) |
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
| Name | Type | Default | Description |
|---|---|---|---|
normalised | bool, optional | True | Defaults 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. |
observations | list | - | 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
| Name | Type | Default | Description |
|---|---|---|---|
normalised | bool, optional | True | if 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. |
observations | list | - | 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
| Name | Type | Default | Description |
|---|---|---|---|
cmap | optional | 'YlGnBu' | |
kwargs | optional | \{\} | |
motifs | list | 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
| Type | Description |
|---|---|
matplotlib.axes.Axes | ax 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
| Name | Type | Default | Description |
|---|---|---|---|
num | int | - | number to be abbreviated |
Returns
| Type | Description |
|---|---|
| str | number in abbreviated string format. |
lorenz
Signature: lorenz(observations)
Returns x coordinates and y coordinates for a Lorenz Curve from a list of observations.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
observations | list | - | list of observations, should be numeric |
ordinal_number
Signature: ordinal_number(number)
Returns ordinal number of integer input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
number | int | - | input number |
Returns
| Type | Description |
|---|---|
| str | ordinal 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
| Name | Type | Default | Description |
|---|---|---|---|
data_type | optional | int | |
motifs | list | np.ndarray | - | 1 dimensional length-40 array of motifs. |
Returns
| Type | Description |
|---|---|
np.ndarray | 6x6 array of motifs whose ijth element is M_ij in Motifs in Temporal Networks (Paranjape et al). |