1
凡例を挿入すると、x軸の極端な右の目盛り( "400")が切り取られます。私がクリッピングのために見つけた2つのソリューションは動作しません。 MikolajMの提案@に基づいて ggplot2:x軸の極端な右の目盛りは、凡例の挿入後にクリップされます。
library(ggplot2)
textsize=12
o2b <- colorRampPalette(c("brown", "orange"))(4)
p <- theme(panel.grid.major=element_blank(), panel.grid.minor=element_blank(),
panel.background=element_blank(), panel.border=element_blank(),
plot.title=element_blank(),
legend.background=element_blank(), legend.key=element_blank(), legend.position=c(1,1),
legend.justification=c(1,1), legend.text=element_text(size=textsize), legend.title=element_text(size=textsize),
axis.line=element_line(colour="black"), axis.text=element_text(size=textsize, colour="black"),
axis.title=element_text(size=textsize))
p1 <- ggplot(temp1, aes(x=rank, y=rhh, colour=factor(naics_level))) + p + geom_point(shape=1, size=2) +
scale_color_manual(values=o2b) +
guides(colour = guide_legend(title="Niveau de NAICS", title.position = "left", reverse=T)) +
labs(x="Rang des MSA", y="Diversité sectorielle basée sur l'emploi en 2015")
# Turn off clipping
library(grid)
# Neither of the two following commands makes a difference
gt <- ggplotGrob(p1)
gt <- ggplot_gtable(ggplot_build(p1))
gt$layout$clip[gt$layout$name=="panel"] <- "off"
grid.draw(gt)
'themeの中に' plot.margin'を入れてみてください – MikolajM
ありがとう@MikolajM。 'plot.margin = unit(c(5.5,12,5.5,5.5)、" pt ")'は私のためにそれを解決しました。 – syre