我有一个带有一些长标签和长标题的图表。我正在使用coord_flip()
,因此由于标签,图表边缘外有很多空间。默认情况下,标题受到图表边缘的限制。
如何使标题超出图表边缘(向左)以便可以跨越整个宽度?以下是一个示例:
ggplot(diamonds, aes(x = cut)) +
geom_bar() +
coord_flip() +
scale_x_discrete("Cut",
labels = c("Fair" = "Fair and a very long extra thing",
"Good" = "Good and a very long extra thing",
"Very Good" = "VG and a very long extra thing",
"Premium" = "P and a very long extra thing. A very long label, just because",
"Ideal" = "I and a very long extra thing")) +
ggtitle("This is my very long title. Long long title. Very long. The Longest. We have the best long titles.")
theme(plot.title = element_text(hjust = 0.95))
? - jorangrid.arrange(ggplot(), top = "标题在此")
将其放置在整个视口上,而不仅仅是在面板上。 - baptiste