简体   繁体   English

如何使用ggplotly更改图形位置

[英]How to change the position of plotly figures using ggplotly

I am trying to remove the legend title using ggplotly without success. 我试图使用ggplotly删除图例标题,但未成功。 I'm sure there is an easy fix, but I cannot find the documentation for it - and removing the legend title (or changing the positioning) using ggplot fails to work. 我敢肯定有一个简单的解决方法,但是我找不到它的文档-使用ggplot删除图例标题(或更改位置)无法正常工作。 See eg: 参见例如:

# Creating the ggplot:
a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), 
y = mpg,fill = interaction(cyl, carb, lex.order = T))) + 
      geom_boxplot() + theme(legend.title=element_blank())
    a # No Legend Title
    # plotly puts back the legend title
    ggplotly(a)

Any ideas how to change / remove the title of the graph? 有任何想法如何更改/删除图形标题? Should it be done using ggplotly or ggplot? 应该使用ggplotly还是ggplot完成?

You can use the labs function: 您可以使用labs功能:

a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), 
y = mpg,fill = interaction(cyl, carb, lex.order = T))) + 
      geom_boxplot()
# update the legend
a <- a + labs(fill= "New Legend")
a
# to remove the label and update the axis texts use:
a <- a+labs(fill= "",x="Cyc/Carb",y="Miles/(US) gallon")
ggplotly(a)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM