I am new to R and recently generate this bubble heatmap using ggplot2. I would like to add colored ticks to top of my figure. I have 7 different colors on the x axis and would like to add a set of colored squares matching to the text, to top of the chart and underneath the label. Thank you and appreciated any help. Please see the link for the data. Text https://drive.google.com/file/d/13mPQaCmhb6pABQ102srafQPryc6r8hNg/view?usp=sharing
Here is my code,
library(ggplot2)
library(ggcorrplot)
library(reshape2)
bb<-c(1, 1.3, 3)
labels<-c("0.1","0.05", "0.001")
x<-c("Blue", "Magenta", "Yellow", "Brown", "Pink", "Red", "Grey")
ggplot(df, aes(x= Var2, y = Var1))+
geom_tile(fill = "white", color = "gray")+
geom_point(aes(color = cor, size = log.P))+
labs(color="Correlation")+
scale_size_continuous(range = c(1,12), name = "P value",
guide = guide_legend(override.aes = list(colour = "grey")), breaks=bb, labels=labels)+
scale_x_discrete(position = "top", limits=x)+
geom_text(aes(label = cor), color = "black", size = 4, vjust=2.5)+
scale_color_gradient2(low = "blue", mid="white", high = "red")+theme_minimal()+
theme(axis.title.x=element_blank(),
axis.title.y=element_blank(),
axis.text.x=element_text(size=15, angle = 40, hjust=0.1, vjust = 0.1, color=x),
axis.text.y=element_text(size=15),
legend.text=element_text(size=15),
legend.title=element_text(size=15),
legend.key.height = unit(0.7,"cm"))
(there are 7 different color modules on x axis)