gg_histo | R Documentation |
Function to plot histograms with specified bin width. See reference: https://www.answerminer.com/blog/binning-guide-ideal-histogram.
gg_histo(
data,
var,
binw_select = "FD",
facet = NULL,
alpha = 0.8,
fill = "steelblue",
colour = "black",
theme_for_histo = theme_minimal(),
title = NULL,
subtitle = NULL
)
data |
Data frame or tibble |
var |
Variable to be plotted |
binw_select |
Specify method to calculate the bin width. "FD" for Freedman-Diaconis (1981) (default), "Sturges" for Sturges (1926), "Scott" for Scott (1979), "Square-root" for Square-root (N/A), or "Rice" for Rice (1944). |
facet |
Variable name to facet wrap by. Default is NULL. |
alpha |
How solid / transparent should the fill be. |
fill |
Fill colour for histrogram. |
colour |
Outline colour of histogram blocks. |
theme_for_histo |
Specify the ggplot theme. Default is theme_minimal(). |
title |
The main title of the plot |
subtitle |
A subtitle for the plot |
library(tidyverse)
gg_histo(data = diamonds,
var = price,
binw_select = "Sturges",
facet = NULL)
gg_histo(data = diamonds,
var = price,
binw_select = "Scott",
facet = clarity)
gg_histo(data = diamonds,
var = price,
binw_select = "FD",
facet = clarity)
gg_histo(data = diamonds,
var = price,
binw_select = "Square-root",
facet = clarity)
ggplot(data = diamonds, aes(x = price)) +
geom_density(alpha = 0.4,
fill = "darkgreen") +
theme_minimal()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.