Tuesday, April 16, 2013

RG#67: Histogram with heatmap color in bars


# data 
set.seed(1234)
XV <- data.frame (x = rnorm(2000, 15, 4))


#plot 

plot1 <- ggplot(data = XV, aes(x = x, y = ..density..)) +
  geom_histogram(aes(fill = ..density..), binwidth = 0.25) +
  stat_density(geom = "path", size = 1, alpha = 0.5) +
  scale_y_continuous(expand = c(0.01, 0)) + scale_fill_gradient(low = "green4", high = "red") + xlab("Time") + ylab("Density") + theme_bw(16, "serif") +
  theme(legend.position = "none")

print(plot1)



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.