Histogram
Draw a basic histogram
# Load ggplot2 package
library(ggplot2)
# Load the diamonds dataset from the ggplot2 package
data(diamonds)
# Draw the basic histogram
ggplot(diamonds, aes(x = price)) +
geom_histogram()
Change the bin size

Use fill and col as attribute:
fill and col as attribute:Change the color of the histogram

Add color to the boundary of the histogram

Use fill as aesthetic:
fill as aesthetic:Last updated