cucurbit
cucurbit

Reputation: 1442

ggplot: reduce width in heatmap

I'm trying to control the width of my heatmap plot. I've already read some posts about it but I can't get the solution. Specifically, I need to reduce the width of the bars. I mean, I have this figure:

enter image description here

I've been able to change to this:

enter image description here

But now I need to remove the grey background and I don't know how. This is the code:

ggplot(data.m.r, 
       aes(x=factor(variable, levels=unique(variable)), 
           y=factor(GO,levels=unique(GO)))) +

  geom_tile(aes(fill = reformat))+ 

  scale_fill_gradient(low = "green",high = "red", na.value="transparent")+ 
  scale_x_discrete(expand = c(1,0))+
  theme(axis.ticks = element_blank(),
        legend.title=element_blank(),
        axis.title.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.x=element_text(color="black",size=8),
        axis.text.y=element_text(color="black",size=4.5))

To obtain the second plot, I've added scale_x_discrete(expand = c(1,0)) to the code but now, I have the grey background. I need to move the "bars" to the left and remove background...

Any suggestion could be really appreciated, Thanks in advance

Upvotes: 0

Views: 2189

Answers (1)

cucurbit
cucurbit

Reputation: 1442

Ok, thanks you guys, finally I found the solution, it is very simple but I had my min blocked after some hours trying to do the same. The solution:

+ theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(), panel.background = element_blank())

I'm quite new at the forum and I don't know if it is correct to answer to my question or it is better to remove the question... But thanks anyway :)

Upvotes: 2

Related Questions