Visualization¶
- netin.viz.handlers.plot_disparity(data: DataFrame | List[DataFrame], col_name: str | List, fn: str | None = None, **kwargs)¶
Plots the disparity of the ranking of the minority group.
Parameters¶
- data: pd.DataFrame or List[pd.DataFrame]
Metadata of nodes (each column is a property, e.g., degree)
- col_name: str
Name of the column to plot (property of node)
- fn: str
File name to save the plot
- kwargs: dict
Additional arguments to pass to the
plot_distribution
function
- netin.viz.handlers.plot_distribution(data: DataFrame | List[DataFrame], col_name: str | List, get_x_y_from_df_fnc: callable, fn=None, **kwargs)¶
Plots a distribution of the values of a column of a dataframe.
Parameters¶
- data: Union[pandas.DataFrame, List[pandas.DataFrame]]
Dataframe or list of dataframes to plot including. A column of this dataframe is used to plot the distribution.
- col_name: str
name of the column to plot
- get_x_y_from_df_fnc: callable
Function to get the x and y values from the dataframe
- fn: str
Filename to save the figure
- kwargs: dict
Additional arguments
- nc: int
number of columns to show in the grid
- cell_size: float or tuple(float, float)
size of the cell in inches. If a tuple is given, the first value is the width and the second value is the height.
- scatter: bool
if True, the distribution is plotted as a scatter plot
- sharex: bool
if True, the x-axis is shared between the subplots
- sharey: bool
if True, the y-axis is shared between the subplots
- ylabel: str
label of the y-axis if not set, the name of the function get_x_y_from_df_fnc is used
- xlabel: str
label of the x-axis.
- xlim, ylim: tuple
limits of the x and y-axis
- hue: str
name of the column to use for grouping the data
- common_norm: bool
If True, the y-axis is normalized to the same value (sum of all values). Otherwise, the y-axis is normalized per class (hue)
- log_scale: tuple(bool, bool)
If True, the x and y-axis are plotted in log scale
- hline_fnc: callable
function to plot a horizontal line
- vline_fnc: callable
function to plot a vertical line
- suptitle: str
title of the whole plot
- cuts: list
list of cuts to plot (vertical lines)
- gini_fnc: callable
function to plot the gini coefficient in ranking (inequality)
- me_fnc: callable
function to plot the mean error in ranking (inequity)
- beta: float
beta value for smoothing the inequity areas (over, under, and fair representation of minority nodes)
- class_label_legend: bool
if True, the legend of the class labels is plotted
And additional arguments sent to
ax.scatter
orax.plot
from matplotlib
- netin.viz.handlers.plot_fraction_of_minority(data: DataFrame | List[DataFrame], col_name: str | List, fn: str | None = None, **kwargs)¶
Plots the fraction of minority nodes in each top-k of the rank.
Parameters¶
- data: pd.DataFrame or List[pd.DataFrame]
Metadata of nodes (each column is a property, e.g., degree)
- col_name: str or List
Name of the column to plot (property of node)
- fn: str:
File name to save the plot
- kwargs: dict
Additional arguments to pass to the
plot_distribution
function
- netin.viz.handlers.plot_gini_coefficient(data: DataFrame | List[DataFrame], col_name: str | List, fn: str | None = None, **kwargs)¶
Plots the Gini coefficient of the ranking of the minority group.
Parameters¶
- data: pd.DataFrame or List[pd.DataFrame]
Metadata of nodes (each column is a property, e.g., degree)
- col_name: str or List[str]
Name of the column to plot (property of node)
- fn: str
File name to save the plot
- kwargs: dict
Additional arguments to pass to the
plot_distribution
function
- netin.viz.handlers.plot_graph(data: Graph | Set[Graph] | List[Graph], share_pos: bool = False, ignore_singletons: bool = False, fn: str | None = None, **kwargs)¶
Plots one or multiple (netin.Graph) graphs as matplotlib figures.
Parameters¶
- data: Union[netin.Graph, Set[netin.Graph]]
graph or set of graphs to plot
- share_pos: bool
if True, the positions of the nodes are shared between the graphs
- ignore_singletons: bool
if True, only nodes with degree > 0 are plotted
- fn: str
filename to save the figure
- kwargs: dict
Additional arguments for the
subplots
function of the figure.- cell_size: float
size of the cell in inches
- nc: int
number of columns
- node_size: int
size of the nodes
- node_shape: str
shape of the nodes e.g, ‘o’ for circle, ‘s’ for square
- edge_width: float
width of the edges
- edge_style: str
style of the edges e.g., ‘solid’, ‘dashed’
- edge_arrows: bool
if True, the edges are plotted with arrows
- arrow_style: str
style of the arrows e.g., ‘-|>’ for filled arrow
- arrow_size: int
size of the arrows
Additional arguments for the
subplots_adjust
andsavefig
functions of the figure.
- netin.viz.handlers.plot_powerlaw_fit(data: DataFrame | List[DataFrame], col_name: str | List, kind: str, fn=None, **kwargs)¶
Plots the powerlaw fit of the data. It shows the empirical and fitted distributions
Parameters¶
- data: pd.DataFrame or List[pd.DataFrame]
Metadata of nodes
- col_name: str or List[str]
Column name of the data to plot (columns of the dataframe, for each (list) or for all (str)
- kind: str
Type of distribution to plot. One of “ccdf”, “cdf”, “pdf”
- fn: str
Name of the file to save the plot
- kwargs: dict
Additional parameters to pass to the plot
- nc: int
Number of columns of the grid
- cell_size: float or tuple(float, float)
size of the cell in inches. If a tuple is given, the first value is the width and the second value is the height.
- sharex: bool
If True, the X axis will be shared among all subplots.
- sharey: bool
If True, the Y axis will be shared among all subplots.
- log_scale: tuple(bool, bool)
If True, the X and Y axis will be in log scale
- xlabel: str
Label of the X axis
- ylabel: str
Label of the Y axis
- verbose: bool
If True, it prints the parameters of the fit
- wspace: float
The amount of width reserved for blank space between subplots, expressed as a fraction of the average axis width
- hspace: float
The amount of height reserved for white space between subplots, expressed as a fraction of the average axis height
- suptile: str
Title of the whole plot
- hue: str
Column name of the data to use to color the plot (groups)
- bbox: tuple(float, float, float, float)
The bounding box that the whole plot will be fitted into. The four values represent (left, bottom, right, top) in figure coordinates.
- loc: str
Location of the legend. One of “best”, “upper right”, “upper left”, “lower left”, “lower right”, “right”, “center left”, “center right”, “lower center”, “upper center”, “center”
Additional parameters to pass to the plot of each subplot (pdf, cdf, ccdf)
- netin.viz.handlers.reset_style()¶
Resets the style of the plots to the default style.