ggplot:将标题扩展到图边距之外

jza*_*dra 4 r ggplot2

我有一个带有一些长标签和长标题的情节。我正在使用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.")
Run Code Online (Sandbox Code Playgroud)

我的情节带有长标签/标题

jor*_*ran 6

也许试试这个:

+ theme(plot.title = element_text(hjust = 0.95))
Run Code Online (Sandbox Code Playgroud)

将标题移过来。