Learn R Programming

DataExplorer (version 0.6.0)

plot_histogram: Create histogram for continuous features

Description

This function creates histogram for each continuous feature.

Usage

plot_histogram(data, title = NULL, ggtheme = theme_gray(),
  theme_config = list(), ...)

Arguments

data

input data

title

plot title

ggtheme

complete ggplot2 themes. The default is theme_gray.

theme_config

a list of configurations to be passed to theme.

other arguments to be passed to geom_histogram.

Details

To change default font family and size, you may pass base_size and base_family to ggtheme options, e.g., ggtheme = theme_gray(base_size = 15, base_family = "serif")

theme_config argument expects all inputs to be wrapped in a list object, e.g., to change the text color: theme_config = list("text" = element_text(color = "blue"))

See Also

geom_histogram plot_density

Examples

Run this code
# NOT RUN {
# Plot iris data
plot_histogram(iris)

# Plot random data with customized geom_histogram settings
set.seed(1)
data <- cbind(sapply(seq.int(4L), function(x) {rnorm(1000, sd = 30 * x)}))
plot_histogram(data, breaks = seq(-400, 400, length = 50))

# Plot histogram with preset ggplot2 themes
library(ggplot2)
plot_histogram(data, ggtheme = theme_light())
plot_histogram(data, ggtheme = theme_minimal(base_size = 15))

# Plot histogram with customized theme components
plot_histogram(data,
theme_config = list(
  "plot.background" = element_rect(fill = "yellow"),
  "aspect.ratio" = 1
))
# }

Run the code above in your browser using DataLab