Back
Close

Computing with Data

elgeish
148.1K views

Smoothing Histograms Using ggplot

The figure below contrasts a histogram with a smoothed histogram using the ggplot function. To enhance the visualization, we made the histogram semi-transparent using the alpha argument (which takes a value between 0 and 1 indicating the transparency level):

ggplot(faithful, aes(x = waiting, y = ..density..)) +
geom_histogram(alpha = 0.3, bins = 30) +
geom_density(size = 1.5, color = "red")
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants