使用ggplot时遇到问题。我的代码shoud afaik给我一个围绕整个情节的框架(plot.background = element_rect(color =“black”)。但是我只得到四分之三的线。有关如何获得4分中的4个的想法吗?
我有这个主题:
theme.plot.bar <- function(){
theme(
text = element_text(family = "sans", face = "plain", colour = "black", size = 12, hjust = 0.5, vjust = 0.5, angle = 0, lineheight = 0.9),
axis.text.x = element_text(size = 13, colour = "black"),
axis.text.y = element_text(size = 11, colour = "black"),
strip.text = element_text(size = rel(0.8)),
axis.text.x = element_text(vjust = 1),
axis.text.y = element_text(hjust = 1),
axis.ticks = element_blank(),
axis.title.x = element_text(),
axis.title.y = element_text(angle = 90),
panel.background = element_rect(fill = NA ,colour = NA),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_line(colour = "black", linetype= "dotted", size =0.6),
strip.text.x = element_text(),
strip.text.y = element_text(angle = -90),
plot.background = element_rect(colour = "black", size = 0.5, linetype= 1, fill="white"), # Kant i højre side kommer ikke med hvis den sættes?
plot.margin = unit(c(0, 1, 0, 0), "cm"),
complete = FALSE)
}
这给了我ggplot的输出:
编辑:将plot.margin改为3厘米:
编辑2:根据要求提供会话信息和ggplot代码 注意:将所有绘图边距设置为2英寸时仍然无效。我用png
sessionInfo() R版本2.15.3(2013-03-01) 平台:x86_64-w64-mingw32 / x64(64位)
x <- factor(pol$job_komp_v2)
df <- as.data.frame(na.omit(x))
names(df) <- "v1"
farve <- rgb(144,26,30, maxColorValue =255)
r <- ggplot(df,aes(x=v1)) +
geom_bar(aes(y = (..count..)/sum(..count..)),
fill=farve, width=0.35) +
scale_y_continuous(labels = percent, "", limits=c(0,1), breaks= c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1)) +
scale_x_discrete(name= "") +
theme.plot.bar()
r