ggplot2 plot without axes, legends, etc

后端 未结 8 1429
执念已碎
执念已碎 2020-11-28 18:23

I want to use bioconductor\'s hexbin (which I can do) to generate a plot that fills the entire (png) display region - no axes, no labels, no background, no nuthin\'.

8条回答
  •  感动是毒
    2020-11-28 18:41

    Current answers are either incomplete or inefficient. Here is (perhaps) the shortest way to achieve the outcome (using theme_void():

    data(diamonds) # Data example
    ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar(aes(fill = cut)) +
          theme_void() + theme(legend.position="none")
    

    The outcome is:


    If you are interested in just eliminating the labels, labs(x="", y="") does the trick:

    ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar(aes(fill = cut)) + 
          labs(x="", y="")
    

提交回复
热议问题