Reputation: 3374
I am trying to remove the legend title using ggplotly without success. 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. See e.g.:
# 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?
Upvotes: 0
Views: 639
Reputation: 17648
You can use the labs
function:
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)
Upvotes: 2