简体   繁体   中英

R: remove background from legend ticks

I have created a geom_tile plot, and used color around some of the tiles and used a scale to color them, but then i get the scales in the legend with a grey background as shown in the figure.

在此处输入图片说明

the plotting is here:

 pl <-  geom_tile(aes(fill=er,x,y, color=factor(tst)), size=2) + scale_color_manual(values=c("#339900", "black", "#0197fd"), name="p-\nvalue",labels=paste(levels(df.new$pval.d),table(df.new$pval.d)))  + geom_point(data=test,aes(x=x,y=y),shape=4,size=3)+guides(col=guide_legend(nrow = 3,keyheight = 3))

I tried to add : theme(legend.key = element_rect(fill = 'white')) to the end of the plotting and theme(legend.key = element_blank()) but both did not work.

how can i remove this grey background from the ticks of the legend .

It's a bit difficult to determine the source of your problem as you didn't provide a reproducable example.

I don't have this problem with my own plots. The solution is probably quite simple: Adding theme_bw() to your plotting code might do the tric.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM