library(ggplot2) library(ggridges) setwd("/Users/henanzhongdizhishen/Desktop/code/ridgeline_plot") data <- read_xlsx("temperature_data.xlsx") #Colormap <- colorRampPalette(rev(brewer.pal(11,'Spectral')))(32) p1 <- ggplot(data, aes(x = Mean.Temperature..F., y = Month)) + geom_density_ridges_gradient(aes(fill = ..x..), scale = 3) + #scale controls the fluctuation level scale_fill_gradientn(colours=c("#5E4FA2","#8ED1A4","#FEFAB6","#F67D4A","#9E0142"), name = "Temp. [F]")+ labs(x = "Mean Temperature [F]", y = "")+ theme_classic() p1 ggsave("p1.pdf",p1,width = 6,height = 4.6) #theme_set(theme_ridges()) p2 <- ggplot(data, aes(x = Mean.Temperature..F., y = Month)) + geom_density_ridges_gradient(aes(fill = Month), scale = 2) + theme(legend.position = "right")+ labs(x = "Mean Temperature [F]", y = "")+ theme_classic() p2 ggsave("p2.pdf",p2,width = 6,height = 4.6)