neurostatx.io.viz
Functions
| Name | Description |
|---|---|
determine_layout | Return a compact subplot grid for nb_axes panels. |
flexible_barplot | Write a multi-panel bar plot from a dataframe. |
flexible_hist | Write a single histogram of all dataframe columns. |
generate_coef_plot | Write a horizontal coefficient bar plot with significance stars. |
determine_layoutfunction#
def determine_layout(nb_axes)Return a compact subplot grid for nb_axes panels.
Parameters
| Name | Type | Description |
|---|---|---|
nb_axes | int | Number of axes to plot. |
Examples
>>> from neurostatx.io.viz import determine_layout>>> determine_layout(4)(2, 2)flexible_barplotfunction#
def flexible_barplot(df, nb_axes, output, cmap='magma', title='Barplot', xlabel=None, ylabel=None)Write a multi-panel bar plot from a dataframe.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
df | pd.DataFrame | required | Values to plot. The index is used as the x-axis and each column is drawn on its own axis. |
nb_axes | int | required | Number of axes to plot. |
output | str | required | Output filename. |
cmap | str | 'magma' | Colormap name. Defaults to "magma". |
title | str | 'Barplot' | Title of the figure. Defaults to "Barplot". |
xlabel | str | None | Label for the x-axis. Defaults to None. |
ylabel | str | None | Label for the y-axis. Defaults to None. |
Examples
>>> import pandas as pd>>> from neurostatx.io.viz import flexible_barplot>>> df = pd.DataFrame({"a": [0.1, 0.2], "b": [0.3, 0.4]}, index=["x", "y"])>>> flexible_barplot(df, nb_axes=2, output="barplot.png")flexible_histfunction#
def flexible_hist(df, output, cmap='magma', title='Histogram', xlabel=None, ylabel=None)Write a single histogram of all dataframe columns.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
df | pd.DataFrame | required | Values to plot. Columns are treated as separate variables. |
output | str | required | Output filename. |
cmap | str | 'magma' | Colormap name. Defaults to "magma". |
title | str | 'Histogram' | Title of the plot. Defaults to "Histogram". |
xlabel | str | None | Label for the x-axis. Defaults to None. |
ylabel | str | None | Label for the y-axis. Defaults to None. |
Examples
>>> import pandas as pd>>> from neurostatx.io.viz import flexible_hist>>> df = pd.DataFrame({"a": [0.1, 0.2, 0.3], "b": [1.0, 1.1, 0.9]})>>> flexible_hist(df, "hist.png")generate_coef_plotfunction#
def generate_coef_plot(df, pval, coefname, varname, output, cmap='magma')Write a horizontal coefficient bar plot with significance stars.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
df | pd.DataFrame | required | Table of coefficients and variable names. |
pval | array - like | required | P-values aligned with df. Values below 0.05 are marked with *. |
coefname | str | required | Name of the column containing the coefficients. |
varname | str | required | Name of the column containing the variable names. |
output | str | required | Output filename. |
cmap | str | 'magma' | Colormap name. Defaults to "magma". |
Examples
>>> import pandas as pd>>> from neurostatx.io.viz import generate_coef_plot>>> df = pd.DataFrame({"var": ["a", "b"], "coef": [0.4, -0.2]})>>> generate_coef_plot(df, [0.01, 0.2], "coef", "var", "coef.png")