Hi this is similar to another post however what I wanted to do here is duplicate x-axis for top and bottom and not just move it to the top. I tried using scale_x_discrete(sec.axis = dup_axis())
but that did not work. Below is my working example
d<- data.frame (pid=c("d","b","c"), type=c("rna","rna","rna"), value = c(1,2,3) )
d2 <- data.frame (pid=c("d","b","c"), type=c("dna","dna","dna"), value = c(10,20,30) )
df <- rbind (d,d2)
ggplot(df, aes(y=pid, x=type ) ) +
geom_tile(aes(fill = value),colour = "white") +
scale_fill_gradient(low = "white",high = "steelblue") +
scale_x_discrete(position = "top")
# this failed: scale_x_discrete(sec.axis = dup_axis())
The plot currently looks like this but I want x to show up top and bottom.