Hi.

I have some continuous variables and I have to draw some histograms.

Does anyone know how to plot 2 overlay histogram in the same graph?

For example, these are my commands for the two histograms

ggplot(data=DATA, aes(x=variable1)) +

geom_histogram(aes(y = stat(count) / sum(count)) , bins = 60,

col="red",

fill="navy",

alpha = .5) +

scale_y_continuous(name = "Percentage", labels = scales::percent) +

scale_x_continuous (name = "" , limits = c(0,150) , breaks = seq(0, 150 , 30) ) +

labs(title= " ") +

theme_bw(base_size = 20) +

theme(plot.title = element_text(hjust = 0.5))

ggplot(data=DATA, aes(x=variable2)) +

geom_histogram(aes(y = stat(count) / sum(count)) , bins = 60,

col="red",

fill="navy",

alpha = .5) +

scale_y_continuous(name = "Percentage", labels = scales::percent) +

scale_x_continuous (name = "" , limits = c(0,150) , breaks = seq(0, 150 , 30) ) +

labs(title= " ") +

theme_bw(base_size = 20) +

theme(plot.title = element_text(hjust = 0.5))

Is there anyway to generate one single chart with histogram of variable 1 and variable 2 overlaid?

Thanks