Plotting
Plotting
graph_plot
color_nodes(ax, g, y, alpha=0.5)
Color node patches based on cluster labels (uses current mpl style colors) applies alpha to nodes and edges
passing color to igraph does not work with matplotlib backend
Parameters:
-
ax
(axis
) –axis to color vertex patches on
-
g
(_type_
) –Igraph graph instance
-
y
(list or ndarray
) –cluster labels
-
alpha
(float
, default:0.5
) –alpha setting for nodes and edges. Defaults to 0.5.
Source code in src/simnetpy/plotting/graph_plot.py
find_cutoff(step)
Find lowest integer where log(k+1) - log(k) < step
Parameters:
-
step
(float
) –step taken in logspace
Returns:
-
int
–cutoff below which integers increment more than step in logspace
-
–
e.g. 5 cutoff for 0.1 as log(5) - log(4) = 0.097 but log(4) - log(3) > 0.1
Source code in src/simnetpy/plotting/graph_plot.py
get_log_bins(x, y, step=0.1, verbose=False)
Function to create log bins for a degree sequence
Parameters:
-
x
(array
) –sequence of node degrees
-
y
(array
) –corresponding counts of each degree
-
step
(float
, default:0.1
) –stepsize in logspace. Lower increase resolution. Min step supported 0.01 Defaults to 0.1.
-
verbose
(bool
, default:False
) –Flag to print resolution and cutoff. Defaults to False.
Returns:
-
_type_
–description
Source code in src/simnetpy/plotting/graph_plot.py
get_log_ticks(max_val, start=0)
helper function to display log ticks on degree plot
Source code in src/simnetpy/plotting/graph_plot.py
log_bin_means(x, y, bins)
Function to calculate the mean y value in each bin. Finds y values for which corresponding x values are within the bin (endpoint not included). Mean is taken over all integers falling within the bin. Mean value and bin midpoints are returned. e.g. x: [2,4, 8], y: [2, 1, 1], bin = [2, 6, 12] gives [4, 9], [(2+1)/4, 1/6]
Parameters:
-
x
(array
) –sequence of node degrees
-
y
(array
) –corresponding counts of each degree
-
bins
(array
) –sequence of bins to get average count in.
Returns:
-
(array, array)
–Returns (bin midpoints, mean value in bin)
Source code in src/simnetpy/plotting/graph_plot.py
plot_degree_dist(degree_dist, logbinsize=0.1, LOG_ONLY=False)
Plot degree distribution as histogram and log-log scatter plot. Linear and log bin sequence shown for log-log plot
Parameters:
-
degree_dist
(numpy array
) –sequence of node degrees.
-
logbinsize
(float
, default:0.1
) –stepsize in logspace. Lower increase resolution. Min step supported 0.01 Defaults to 0.1.
Source code in src/simnetpy/plotting/graph_plot.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
plot_graph_colored_nodes(g, y=None, ax=None, vs=None, alpha=0.5)
Plot network and cluster nodes
Parameters:
-
g
(_type_
) –network to plot
-
y
(_type_
, default:None
) –cluster labels. Defaults to one single cluster.
-
ax
(_type_
, default:None
) –axis to plot on if given. Defaults to None.
-
vs
(_type_
, default:None
) –visual style dict for igraph. Defaults to DEFAULT_VS if nothing passed.
-
alpha
(float
, default:0.5
) –level of transparancey for nodes and edges. Defaults to 0.5.
Returns:
-
–
fig, ax: if ax passed fig is None.