繁体   English   中英

如何使用ggplotly更改图形位置

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

我试图使用ggplotly删除图例标题,但未成功。 我敢肯定有一个简单的解决方法,但是我找不到它的文档-使用ggplot删除图例标题(或更改位置)无法正常工作。 参见例如:

# 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)

有任何想法如何更改/删除图形标题? 应该使用ggplotly还是ggplot完成?

您可以使用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