Forest plot
Creating forest plots from contrast objects.
forest_plot
forest_plot (contrasts:List, selected_indices:Optional[List]=None, contrast_type:str='delta2', xticklabels:Optional[List]=None, effect_size:str='mean_diff', contrast_labels:List[str]=None, ylabel:str='value', plot_elements_to_extract:Optional[List]=None, title:str='ΔΔ Forest', custom_palette:Union[dict,list,str,NoneType]=None, fontsize:int=20, violin_kwargs:Optional[dict]=None, marker_size:int=20, ci_line_width:float=2.5, zero_line_width:int=1, remove_spines:bool=True, ax:Optional[matplotlib.axes._axes.Axes]=None, additional_plotting_kwargs:Optional[dict]=None, rotation_for_xlabels:int=45, alpha_violin_plot:float=0.4, horizontal:bool=False)
Custom function that generates a forest plot from given contrast objects, suitable for a range of data analysis types, including those from packages like DABEST-python.
Type | Default | Details | |
---|---|---|---|
contrasts | List | List of contrast objects. | |
selected_indices | Optional[List] | None | Indices of specific contrasts to plot, if not plotting all. |
contrast_type | str | delta2 | |
xticklabels | Optional[List] | None | Custom labels for the x-axis ticks. |
effect_size | str | mean_diff | Type of effect size to plot (e.g., ‘mean_diff’, ‘median_diff’). |
contrast_labels | List[str] | None | Labels for each contrast. |
ylabel | str | value | Label for the y-axis, describing the plotted data or effect size. |
plot_elements_to_extract | Optional[List] | None | Elements to extract for detailed plot customization. |
title | str | ΔΔ Forest | Plot title, summarizing the visualized data. |
custom_palette | Optional[Union[dict, list, str]] | None | Custom color palette for the plot. |
fontsize | int | 20 | Font size for text elements in the plot. |
violin_kwargs | Optional[dict] | None | Additional arguments for violin plot customization. |
marker_size | int | 20 | Marker size for plotting mean differences or effect sizes. |
ci_line_width | float | 2.5 | Width of confidence interval lines. |
zero_line_width | int | 1 | Width of the line indicating zero effect size. |
remove_spines | bool | True | If True, removes top and right plot spines. |
ax | Optional[plt.Axes] | None | Matplotlib Axes object for the plot; creates new if None. additional_plotting_kwargs : Optional[dict], default=None Further customization arguments for the plot. |
additional_plotting_kwargs | Optional[dict] | None | |
rotation_for_xlabels | int | 45 | Rotation angle for x-axis labels, improving readability. |
alpha_violin_plot | float | 0.4 | Transparency level for violin plots. |
horizontal | bool | False | New argument for horizontal orientation |
Returns | plt.Figure | The matplotlib figure object with the generated forest plot. |
extract_plot_data
extract_plot_data (contrast_plot_data, contrast_type)
Extracts bootstrap, difference, and confidence intervals based on contrast labels.
load_plot_data
load_plot_data (contrasts:List, effect_size:str='mean_diff', contrast_type:str='delta2')
Loads plot data based on specified effect size and contrast type.
Type | Default | Details | |
---|---|---|---|
contrasts | List | List of contrast objects. | |
effect_size | str | mean_diff | |
contrast_type | str | delta2 | |
Returns | List |