没有坐标轴,图例等的ggplot2绘图 [英] ggplot2 plot without axes, legends, etc

查看:163
本文介绍了没有坐标轴,图例等的ggplot2绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用bioconductor的hexbin(我可以这样做)来生成一个填充整个(png)显示区域的图 - 无轴,无标签,无背景,无nuthin。


根据我在Chase的回答中的评论,你可以使用 element_blank 删除很多这些东西:

解决方案 (10),y = runif(10))
$($) b $ bp <-ggplot(dat,aes(x = x,y = y))+
geom_point()+
scale_x_continuous(expand = c(0,0))+
scale_y_continuous(expand = c(0,0))

p + theme(axis.line = element_blank(),axis.text.x = element_blank(),
axis.text.y = element_blank(),axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),legend.position =none,
panel.background = element_blank(),panel.border = element_blank(),panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), plot.background = element_blank())

看起来围绕边缘的边距仍然很小导致.png当我保存这个。或许其他人知道如何删除该组件。



(历史记录:自 ggplot2 版本0.9.2, opts 已被弃用,而是使用 theme()并将 theme_blank()替换为 element_blank()。)


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'.

解决方案

As per my comment in Chase's answer, you can remove a lot of this stuff using element_blank:

dat <- data.frame(x=runif(10),y=runif(10))

p <- ggplot(dat, aes(x=x, y=y)) + 
        geom_point() +
        scale_x_continuous(expand=c(0,0)) + 
        scale_y_continuous(expand=c(0,0))   

p + theme(axis.line=element_blank(),axis.text.x=element_blank(),
          axis.text.y=element_blank(),axis.ticks=element_blank(),
          axis.title.x=element_blank(),
          axis.title.y=element_blank(),legend.position="none",
          panel.background=element_blank(),panel.border=element_blank(),panel.grid.major=element_blank(),
          panel.grid.minor=element_blank(),plot.background=element_blank())

It looks like there's still a small margin around the edge of the resulting .png when I save this. Perhaps someone else knows how to remove even that component.

(Historical note: Since ggplot2 version 0.9.2, opts has been deprecated. Instead use theme() and replace theme_blank() with element_blank().)

这篇关于没有坐标轴,图例等的ggplot2绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆