I am trying to make heatmap using ggplot2 using the geom_tiles function geom_tiles here is my code below:
p<-ggplot(data,aes(Treatment,organisms))+geom_tile(aes(fill=S))+ scale_fill_gradient(low = "black",high = "red") + scale_x_discrete(expand = c(0, 0)) + scale_y_discrete(expand = c(0, 0)) + theme(legend.position = "right", axis.ticks = element_blank(), axis.text.x = element_text(size = base_size, angle = 90, hjust = 0, colour = "black"), axis.text.y = element_text(size = base_size, hjust = 1, colour = "black")).
- my data.csv file
my x axis - types of treatment
my Y axis - species of organisms
I'm not too familiar with commands and programming, and I'm relatively new to this. I just want to indicate the order of the labels on the x axis. In this case, I am trying to indicate the order of "treatment". By default, it is ordered alphabetically. How do I override this / save the data in the same order as in my csv source file?
I tried this command
scale_x_discrete(limits=c("Y","X","Z"))
where x, y and z are my order of processing conditions. However, it does not work very well, and I do not have enough heat boxes.
r r-faq ggplot2
Lisa Ta Oct 08 '12 at 1:10 2012-10-08 01:10
source share