我试图制作一个没有数据之外的信息的情节.没有轴; 没有网格; 无题; 只是情节.
但我不断获得额外的利润和填充,我无法删除.
library(ggplot2)
library(grid)
theme_bare <- 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(),
#axis.ticks.length = unit(0, "lines"), # Error
axis.ticks.margin = unit(c(0,0,0,0), "lines"),
legend.position = "none",
panel.background = element_rect(fill = "gray"),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.margin = unit(c(0,0,0,0), "lines"),
plot.background = element_rect(fill = "blue"),
plot.margin = unit(c(0,0,0,0), "lines")
)
ggplot() +
geom_area (data=economics, aes(x = date, y = unemploy), linetype=0) +
theme_bare
Run Code Online (Sandbox Code Playgroud)
生成此图片: 
我想要的是这个: 
我无法弄清楚如何摆脱蓝色,使深灰色与边缘齐平.
任何人都可以提供一些建议吗?
koh*_*ske 29
以下是仅绘制面板区域的方法:
p <- ggplot() + geom_area (data=economics, aes(x = date, y = unemploy), linetype=0) +
scale_x_date(expand = c(0,0)) + scale_y_continuous(expand = c(0,0)) +
theme(line = element_blank(),
text = element_blank(),
title = element_blank())
gt <- ggplot_gtable(ggplot_build(p))
ge <- subset(gt$layout, name == "panel")
grid.draw(gt[ge$t:ge$b, ge$l:ge$r])
Run Code Online (Sandbox Code Playgroud)

Hen*_*rik 21
从ggplot2_2.0.0你可以使用theme_void:
ggplot() +
geom_area(data = economics, aes(x = date, y = unemploy), linetype = 0) +
theme_void()
Run Code Online (Sandbox Code Playgroud)
bap*_*ste 10
尝试
last_plot() + theme(axis.ticks.length = unit(0.001, "mm")) + labs(x=NULL, y=NULL)
Run Code Online (Sandbox Code Playgroud)
您可能想要为0刻度长度提交错误.