![](/img/trans.png)
[英]How to change the legend position when transfer ggplot2 to plotly using `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.