trifusion.base.plotter module¶
-
trifusion.base.plotter.
bar_plot
(*args, **kwargs)[source]¶ Creates a bar plot from a data array.
If a multi-dimensional array is provided, it will create a stacked bar plot.
Parameters: data : numpy.array
Single or multi-dimensional array with plot data.
labels : list
List of xtick labels. Should have the same length as data.
title : str
Title of the plot.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
lgd_list : list
For categorical plots, provide the label of each category.
reverse_x : bool
If True, reverse the x-axis orientation.
table_header : list
List with the header of the table object. Each element represents a column.
Returns: fig : matplotlib.Figure
Figure object of the plot.
lgd : matplotlib.Legend
Legend object of the plot.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
box_plot
(*args, **kwargs)[source]¶ Creates box (whisker) plot.
Parameters: data : numpy.array
Single or multi-dimensional array with plot data.
labels : list
List of xtick labels. Should have the same length as data.
title : str
Title of the plot.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
Returns: fig : matplotlib.pyplot.Figure
Figure object of the plot.
_ : None
Placeholder for the legend object. Not used here but assures consistency across other plotting methods.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
histogram_plot
(*args, **kwargs)[source]¶ Creates an histogram from data.
Parameters: data : numpy.array
Array with plot data.
title : str
Title of the plot.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
table_header : list
List with the header of the table object. Each element represents a column.
real_bin_num : bool
If True, then the table data will be forced to be in real numbers.
Returns: fig : matplotlib.Figure
Figure object of the plot.
lgd : matplotlib.Legend
Legend object of the plot.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
histogram_smooth
(data, ax_names=None, table_header=None, title=None, legend=None)[source]¶ Creates a smooth histogram-like plot.
Creates a smooth line plot with colored areas with the same distribution as an histogram. It supports a multi-dimensional array, in which case each array will be used to create vertically stacked subplots.
Parameters: data : numpy.array
Array with plot data.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
table_header : list
List with the header of the table object. Each element represents a column.
title : str
Title of the plot.
legend : list
If using a multi-dimensional array, provide the name of each subplot.
Returns: fig : matplotlib.pyplot.Figure
Figure object of the plot.
_ : None
Placeholder for the legend object. Not used here but assures consistency across other plotting methods.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
interpolation_plot
(*args, **kwargs)[source]¶ Creates black and white interpolation plot
Creates a black and white interpolation plot from data, which must consist of a 0/1 matrix for absence/presence of taxa in genes.
Parameters: data : numpy.array
Single or multi-dimensional array with plot data.
title : str
Title of the plot.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
Returns: fig : matplotlib.pyplot.Figure
Figure object of the plot.
_ : None
Placeholder for the legend object. Not used here but assures consistency across other plotting methods.
_ : None
Placeholder for the table header list. Not used here but assures consistency across other plotting methods.
-
trifusion.base.plotter.
multi_bar_plot
(*args, **kwargs)[source]¶ Creates a multiple bar plot.
Creates a multiple bar plot from a multi-dimensional array. The bar plots from each array will be grouped and displayed side by side.
Parameters: data : numpy.array
Single or multi-dimensional array.
labels : list
List of xtick labels. Should have the same length as data.
title : str
Title of the plot.
lgd_list : list
For categorical plots, provide the label of each category.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
Returns: fig : matplotlib.Figure
Figure object of the plot.
lgd : matplotlib.Legend
Legend object of the plot.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
outlier_densisty_dist
(*args, **kwargs)[source]¶ Creates a density distribution for outlier plots.
Parameters: data : numpy.array
1D array containing data points.
outliers : numpy.array
1D array containing the outliers.
outliers_labels : list or numpy.array
1D array containing the labels for each outlier.
title : str
Title of the plot.
Returns: fig : matplotlib.Figure
Figure object of the plot.
lgd : matplotlib.Legend
Legend object of the plot.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
scatter_plot
(*args, **kwargs)[source]¶ Generates a scatter plot from a 2D array.
Builds a scatter plot from a 2D array. Also calculates the correlation coefficient if requested by the correlation argument.
Parameters: data : numpy.array
2D array containing the x and y data points.
correlation : bool
If True, the spearman’s rank correlation coefficient is calculated and added to the plot as an annotation
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
table_header : list
List with the header of the table object. Each element represents a column.
title : str
Title of the plot.
Returns: fig : matplotlib.pyplot.Figure
Figure object of the plot.
_ : None
Placeholder for the legend object. Not used here but assures consistency across other plotting methods.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
set_props
(func)[source]¶ Decorator used to set general plot attributes
This decorator is use to automatically set several plot properties based on the arguments provided to the plotting functions. In this way, there is no need to write repetitive code in each function. The accepted arguments are:
- ax_names : list. Axis names. First element is x-axis label, second is y-axis label
- title : str. Title of the plot
-
trifusion.base.plotter.
sliding_window
(*args, **kwargs)[source]¶ Creates a sliding window plot.
Parameters: data : numpy.array
Array with plot data.
window_size : int
Length of window size for sliding window.
table_header : list
List with the header of the table object. Each element represents a column.
title : str
Title of the plot.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
Returns: fig : matplotlib.pyplot.Figure
Figure object of the plot.
_ : None
Placeholder for the legend object. Not used here but assures consistency across other plotting methods.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
stacked_bar_plot
(*args, **kwargs)[source]¶ Creates a stacked bar plot.
Parameters: data : numpy.array
Multi-dimensional array.
labels : list
List of xtick labels. Should have the same length as data.
title : str
Title of the plot.
table_header : list
List with the header of the table object. Each element represents a column.
title : str
Title of the plot.
ax_names : list
List with the labels for the x-axis (first element) and y-axis (second element).
normalize : bool
If True, values of the data array will be normalized by the normalize_factor
normalize_factor : int or float
Number used to normalize values of the data array.
Returns: fig : matplotlib.Figure
Figure object of the plot.
lgd : matplotlib.Legend
Legend object of the plot.
table : list
Table data in list format. Each item in the list corresponds to a table row.
-
trifusion.base.plotter.
triangular_heat
(*args, **kwargs)[source]¶ Creates a triangular heatmap plot.
Parameters: data : numpy.array
Triangular array with plot data.
labels : list
List of xtick labels. Should have the same length as data.
title : str
Title of the plot.
color_label : str
Label for colorbar.
Returns: fig : matplotlib.pyplot.Figure
Figure object of the plot.
_ : None
Placeholder for the legend object. Not used here but assures consistency across other plotting methods.
table : list
Table data in list format. Each item in the list corresponds to a table row.