beautifulplots
Submodules
Package Contents
Functions
Dictionary of plot parameters. Each parameter coresponds and corresponding value. |
|
|
Receives as input a dictionary of plot options and applies the options to the maxtplotlib axis and graph. |
|
process **kwargs options corresponding to the plot_defaults dictionary (see above) |
|
|
|
Bar plot function designed for ease of use and aesthetics. |
Attributes
- beautifulplots.__version__
- beautifulplots.plot_defaults()[source]
Dictionary of plot parameters. Each parameter coresponds and corresponding value. See also get_plot_options for extracting plot options from **kwargs.
Axis - x, y, and plot area parameters
- Parameters
df (DataFrame) – The input DataFrame containing colums corresponding to bar values and columns.
title (String) – corresponds to the axis title. default = ‘’
titlefontsize – font size of the axis title, default = 18
legend_loc (String) – Matplotlib legend location, for example, upper right , default = “best”.
legend_loc2 (String) – Secondary axis legend location, for example, upper right , default = best.
xlims – (xmin, xmax), minimum and maximum x-values of the axis. default = None, in which case the min and max are set automatically by matplotlib.
ylims – (ymin,ymax), minimum and maximum y-values of the axis. default = None, in which case the min and max are set automatically by matplotlib.
ylims2 – (ymin,ymax), minimum and maximum y-values of the secondary axis. default = None, in which case the min and max are set automatically by matplotlib.
xlabelfontsize – default = 16
xticklabelsize – default = 16
xtickfontsize – default = 16
xtickrotation – default = 0
ylabelfontsize – ylabel font size, default = 16
ytickfontsize – xtick label font size, default = 16
ytickrotation – Rotation of the xtick label, default = 0
legendfontsize – legend font size, default = 16
xlabel (String) – xlabel title, default = ‘’
ylabel (String) – ylable title, default = ‘’
Line, Scatter Plots
- Parameters
marker – Matplotlib line markers. default = None (Matplotlib default).
marker2 – Secondary axis, Matplotlib line marker. default = None (Matplotlib default).
yaxis_currency (Boolean) – Boolean default = False.
ytick_format (String) – String default = None (Matplotlib default).
alpha (fraction) – Trasnparancy (opacity), default = None (not transparent)
alpha2 (fraction) – Secondary axis, default = 0.5, 50% opacity
legend_labels (list) – Overide default legend labels. default = None (do not override)
estimator – seaborn barplot summary estimator, default = sum
estimator2 – secondary axis, seaborn barplot summary estimator, default = sum
color – default = None, indicateing Matplolib default (Matplotlib default)
color2 – secondary axis line, bar or color. defualt = None (Matplotlib default)
palette – colormap, default = None
palette2 – colormap, default = None, secondary y axis.
hue – dimension value for corresponding Seaborn graphs, default = None.
ci – Seaborn confidence interval parameter: float, sd, or None
ci2 – Seaborn confidence interval parameter second y axis: float, sd, or None
Plots and subplots
Parameters corresponding to the plot or subplot characteristics. They are used when matplot_helpers functions create the plot figure and axis, otherewise, these parameters do not affect the plot.
- Parameters
plotstyle (String) – matplotlib plotstyle
figsize – total size (height, width) in inches of the figure, including total plotting area of all subplots and spacing
wspace – width space (horizontal) between subplots, default wspace = 0.2
hspace – height space (vertical) between subplots, default hspace = 0.2
legendloc – default=best
Returns
Dictionary: {parameter1:value1, parameter2:value2, … }. Pairs of plat parameters and corresponding values.
- beautifulplots.set_axisparams(options_dict, ax, g)[source]
Receives as input a dictionary of plot options and applies the options to the maxtplotlib axis and graph.
- Parameters
options_dict (dictionary) – Dictionary where each key, value pair corresponds to plot parameter
ax (axis) – matplotlib axis to apply the plot options
g (graph) – matplotlib graph to apply the plot options
- Returns
returns None if the function completes without errors.
- Return type
None
- beautifulplots.get_kwargs(**kwargs)[source]
process **kwargs options corresponding to the plot_defaults dictionary (see above) If a beautifulplots plot_option dictionary key is contained in the **kwargs then the plot_defautls[key] value is replaced with that found in **kwargs.
- Returns
{parameter1:value1, parameter2:value2, …} dictionary corresponding to plot options
- Return type
Dictionary
- beautifulplots.set_yaxis_format(ax, yaxisformat='1.2f', ycurrency=None, labelcolor='black', which='major')[source]
- beautifulplots.barplot(df, bar_columns, bar_values, barcurrency=None, barorientation='v', bardataformat='1.2f', y2=None, estimator=sum, estimator2=sum, ax=None, bardatalabels=False, test_mode=False, bardatafontsize=14, **kwargs)[source]
Bar plot function designed for ease of use and aesthetics. The underlying barplot is ased on the Seaborn with additions, such as secondary axis, data labels, and improved default parameters. Refer to beautifulplots plot_defaults for a complete list of options.
- Parameters
df (DataFrame) – The input DataFrame containing colums corresponding to bar_plot values (“bar_values”) and column names (see examples in documentation)
bar_columns – Datafrae columns corresponding to bar column names
bar_values – Dataframe column corresponding to bar column values
ax (axis) – matplotlib axis (optional), default = None. If axis is None, then create a matplolib figure, axis to host the barplot
color – Matplotlib compatabile color name as text or RGB values, for example, color = [51/235,125/235,183/235].
palette – Matplotlib compatible color palette name, for example, “tab20”
hue – Name of hue dimension variable (i.e., DataFrame column name)
ci – Seaborn confidence interval parameter: float, sd, or None, default = None
barorientation – default = v (vertical), or h (horizontal)
barcurrency – default = False (bar values do not represent currency). True (bar values represent currency, append $ to the value)
bardatalabels (Boolean) – default = False (data labels not included)
estimater – default = sum. Specifies how to aggregate plot bar data.
estimator2 – default = None. Summarize y2 asis daa. Default is no aggregation, do not summarize y2 axis data.
options (additional) – see kale.plot_defaults for additional input variables.
- Returns
returns True if processing completes succesfully (without errors).
- beautifulplots.lineplot(df, x, y, y2=None, ax=None, test_mode=False, estimator=None, estimator2=None, **kwargs)[source]
Lineplot function designed for ease of use and aesthetics. Based on the Seaborn lineplot, with additions such as secondary axis, ease of use, and improved default parameters. Refer to beautiful plot_defaults for full list of options.
- Parameters
df (Dataframe) – The input DataFrame containing colums corresponding to x and y
x – Dataframe column corresponding to the lineplot x-axis aldfsd;lfj
y – Dolumn or list of columns corresponding to the lineplot y-axis
y2 – Column or list of columns correspondng to the secondary axis, default = None
yaxisformat – default = “1.2f”
ycurrency – default = None. Primary y-axis. For example = “$” to prepend dollar symbol.
y2currency – default = None. Secondary y-axis. For example = “$” to prepend dollar symbol.
marker – default = None. Primary y-axis. Matplotlib line marker. If y is a list, then marker must be a list of markers.
marker2 – default = None. Secondary y-axis. Matplotlib line marker. If y2 is a list, then marker2 must be a list of markers.
estimator – Specifies how to summarize data corresponding to y-axis. Defaults to plot all data points do not summarize.
estimator2 – Specifies how to summarize data corresponding to y2-axis. Defaults to plot all data points do not summarize.
- Returns
returns None if processing completes succesfully (without errors).