ggplot legend at top but below title?

前端 未结 1 2250
予麋鹿
予麋鹿 2021-02-20 05:16

Is there a way to make ggplot place the legend on top but below the title?

As an example...

\"enter

相关标签:
1条回答
  • 2021-02-20 05:33

    Edit Ignore this. The issue is not longer a problem. But the code has been updated so that it no longer throws an error.

    While waiting for the next version, you can fine tune within ggplot2. For instance:

    ggplot(carrots, aes(y = Yield, x = Field, fill = Breed)) + 
      geom_bar(stat = "identity") + 
      theme(
         plot.margin = unit(c(2, 1, 1, 1), "cm"), 
         plot.title = element_text(size = 30, face = "bold", colour = "blue", vjust = 7), 
         legend.direction = "horizontal",
         legend.position = c(0.1, 1.05)) + 
       ggtitle("Title") +
      labs(fill = "") 
    
    0 讨论(0)
提交回复
热议问题