ich derzeit Plots bin entfernen mit ggplot2 für ein Latex-Dokument und entdeckt zu schaffen, dass ggplot2 viele unerwünschte Ränder ergänzt:Wie Margen in ggplot2 Chart
- rot gemalt von
plot.background=element_rect(fill="red")
:- kleiner Rand links
- kleiner Rand zwischen Bild und Legende
- gemalt violett mit photoshop:
- Rand auf der linken und der rechten Seite
- 1px Marge am unteren
Welche Regeln mehr benötigt werden, um diese Ränder zu entfernen ? Es ist wirklich schwierig, all diese Konfigurationsoptionen zu googeln. Dies ist meine aktuelle Chart:
library(ggplot2)
library(scales)
label <- c("A", "B", "C", "D")
value <- c(61, 26, 9, 4)
values <- data.frame(label, value)
myplot <- ggplot(values, aes(x = "", y=value, fill=label))
myplot <- myplot + theme(legend.position="bottom")
myplot <- myplot + labs(fill="")
myplot <- myplot + geom_bar(stat="identity", width=1)
myplot <- myplot + geom_text(
aes(x=1.3, y=value/2+c(0, cumsum(value)[-length(value)])),
label=percent(value/100),
size=2
)
myplot <- myplot + coord_polar(theta="y")
myplot <- myplot + theme(plot.background=element_rect(fill="red"))
myplot <- myplot + theme(
plot.margin=unit(c(0,0,0,0), "mm"),
legend.margin=unit(0, "mm"),
axis.title=element_blank(),
axis.ticks=element_blank()
)
ggsave("pie.pdf")
Dupe? [Plot-Ränder entfernen in 'ggplot2'] (http://stackoverflow.com/a/17791455/903061) sagt' labs (x = NULL, y = NULL) 'wird auch benötigt. – Gregor
Allerdings scheint es nicht wirklich zu helfen, zumindest nicht mit dem roten Bereich. – Gregor
Warum entfernen Sie nicht einfach '' myplot <- myplot + theme (plot.background = element_rect (fill = "red")) ''? –