pyxplor.plot_numeric
Module Contents
Functions
|
Plot the distribution of numeric variables in a DataFrame, save the plot, and display it. |
- pyxplor.plot_numeric.plot_numeric(input_df: pandas.DataFrame, list_of_variables: list, plot_kind: str, figsize: tuple = (8, 10), output: bool = False, super_title: str = 'Distribution of Numeric Variables', super_title_font: int = 14, color: str = 'lightblue', mean_color: str = 'orange', median_color: str = 'red') None[source]
Plot the distribution of numeric variables in a DataFrame, save the plot, and display it.
This function will construct a set of subplots for each of the numeric variables specified in list_of_variables. The function will save as well as display the entire figure.
- Parameters:
input_df (pd.DataFrame) – The DataFrame that contains the numeric variables.
list_of_variables (list) – List of numeric variables (column names) to be plotted.
plot_kind ({'hist', 'kde', 'hist+kde'}) – Type of plot to be generated: ‘hist’: Histogram only. ‘kde’: Kernel density estimate plot only. ‘hist+kde’: Histogram with a kernel density estimate plot showing median and mean.
figsize (tuple[int, int], optional) – The width and height of the figure size in a tuple. Default is (8, 10).
output (bool, optional) – Whether to output the figure to the current working directory. Default is False.
super_title (str, optional) – Super title for the entire plot. Default is “Distribution of Numeric Variables”.
super_title_font (int, optional) – Font size for the super title. Default is 14.
color (str, optional) – Color for the plot elements. If None, the default color palette will be used.
mean_color (str, optional) – Color for the mean line. If None, the default color will be used.
median_color (str, optional) – Color for the median line. If None, the default color will be used.
- Returns:
fig (matplotlib.figure.Figure) – The matplotlib Figure object.
ax (matplotlib.axes.Axes or array of Axes) – The matplotlib Axes object(s).
Examples
numeric = [“numeric_var1”, “numeric_var2”] plot_numeric(df, numeric, “hist+kde”)