Skip to contents

this will produce a ggplot2 or plotly histogram plot of the density information provided from the hai_get_density_data_tbl function.

Usage

hai_density_plot(
  .data,
  .dist_name_col,
  .x_col,
  .y_col,
  .size = 1,
  .alpha = 0.382,
  .interactive = FALSE
)

Arguments

.data

The data that is produced from using hai_get_density_data_tbl

.dist_name_col

The column that has the distribution name, should be distribution and that is set as the default.

.x_col

The x value from the tidied density object.

.y_col

The y value from the tidied density object.

.size

The size parameter for ggplot.

.alpha

The alpha parameter for ggplot.

.interactive

This is a Boolean fo TRUE/FALSE and is defaulted to FALSE. TRUE will produce a plotly plot.

Value

A plot, either ggplot2 or plotly

Details

This will produce a density plot of the density information that is produced from the function hai_get_density_data_tbl. It will look for an attribute from the .data param to ensure the function was used.

See also

Other Distribution Plots: hai_density_hist_plot(), hai_density_qq_plot()

Author

Steven P. Sanderson II, MPH

Examples

library(dplyr)

df <- hai_scale_zero_one_vec(.x = mtcars$mpg) %>%
  hai_distribution_comparison_tbl()

tidy_density_tbl <- hai_get_density_data_tbl(df)

hai_density_plot(
  .data = tidy_density_tbl,
  .dist_name_col = distribution,
  .x_col = x,
  .y_col = y,
  .alpha = 0.5,
  .interactive = FALSE
)