Description Usage Arguments Examples
This function creates nicely formatted, standardized density plots.
1 2 3 4 5 | plot_density(df, x, fill = NULL, facet = NULL, position = "identity",
ticks = 5, angle = 0, title = TRUE, subtitle = NULL,
caption = NULL, lab_x = "Value range", lab_y = "Density",
legend = TRUE, vline = c(NaN), alpha = 0.7, quantile_low = 0,
quantile_high = 1, theme_type = "ipsum", palette = "awtools")
|
df |
A data frame. |
x |
A numerical variable to plot its density. |
fill |
Select an additional grouping variable to be used for density plotting. Defaults to NULL. |
facet |
Select an additional faceting variable to create facets. Defaults to NULL. |
position |
Select the positional adjustment of the plot. Possible values are: "identity" (default), "stack" or "fill" |
ticks |
Select the number of ticks on the x and y axis with the |
angle |
Select the rotation angle for the x axis labels. Defaults to 0. |
title |
Should the plot title appear automatically. Defaults to TRUE. |
subtitle |
Text that is displayed on the subtitle. Defaults to NULL. |
caption |
Text that is displayed on the caption. Defaults to NULL. |
lab_x |
Text that is displayed on the x axis. Defaults to "Value range". |
lab_y |
Text that is displayed on the y axis. Defaults to "Density". |
legend |
Should the plot legend appear automatically. Defaults to TRUE. |
vline |
Should any vertical lines be added to the plot. Defaults to c(NaN). |
alpha |
Select plot fill transparency. Defaults to 0.7. |
quantile_low |
Select lower percentile for outliers exclusion. Defaults to 0.0%. |
quantile_high |
Select upper percentile for outliers exclusion. Defaults to 1.0%. |
theme_type |
Select a theme type from themes available in the |
palette |
Select a palette type with the |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | diamonds %>%
plot_density(x = carat)
diamonds %>%
plot_density(x = carat,
fill = cut)
diamonds %>%
plot_density(x = carat,
fill = cut,
position = "stack")
diamonds %>%
plot_density(x = carat,
fill = cut,
position = "fill")
diamonds %>%
plot_density(x = carat,
facet = cut)
diamonds %>%
plot_density(x = carat,
fill = cut,
facet = cut,
alpha = .5)
diamonds %>%
plot_density(x = carat,
fill = cut,
facet = cut,
title = "Write your title here",
subtitle = "Write your subtitle here",
caption = "Write your caption here",
lab_x = "Carat",
alpha = .5,
vline = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.