爲了獲得更好的可視化效果,我需要將構面的條形文本移動到每個構面的頂部。R:ggplot2:將strip.text從「y」軸更改爲多面圖中的「x」軸?
現在他們在右側,但我需要他們頂部。
這是我的代碼:
tvs.rangos <- ggplot(tvs , aes(rangos))
tvs.rangos + geom_histogram(aes(fill = marca), width = .7) + labs(title = "Marcas de TV por rangos de precios",
x = "rango de precios", y = "cantidad de tvs") +
facet_grid(ecommerce ~ .) +
scale_fill_brewer(palette="Set3") +
theme(axis.text.x = element_text(colour="grey10",size=16,hjust=.5,vjust=.5,face="bold"),
axis.text.y = element_text(colour="grey10",size=18,,hjust=1,vjust=0,face="plain"),
axis.title.x = element_text(colour="grey40",size=12,angle=0,hjust=.5,vjust=0,face="plain"),
axis.title.y = element_text(colour="grey40",size=12,angle=90,hjust=.5,vjust=.5,face="plain"),
plot.title = element_text(size = 16,vjust=2),
legend.title = element_text(colour="grey40", size=16, face="bold"),
legend.text = element_text(colour="grey10", size=16, face="bold"),
strip.text.y = element_text(size = 20, angle = 0))
我發現這個話題:
ggplot2: Using gtable to move strip labels to top of panel for facet_grid
不過,我正在尋找一個simplier方法,如果有的話。
你能提供的數據(你的對象tvs.rangos),這樣更容易爲人們幫助一個簡單的例子嗎? – tagoma
也許你可以嘗試使用'coord_flip'和'scale_x_reverse'就像他們在這裏所做的:http://stackoverflow.com/questions/29504883/ggplot2-how-to-swap-y-axis-and-right-facet-strip-以及如何訂購的方面值 – tagoma