I've got an issue when using ggplotly()
to a ggplot
graph: the y axis disappears. Here's a reproducible example using iris
dataset (this example is quite dump, but whatever)
data(iris)
g = ggplot(data = iris, aes(x = Petal.Length, y = Petal.Width, fill = Species)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_manual(name = "legend", values = c("blue", "red", "green")) +
ylab("Y title") +
ylim(c(0,3)) +
xlab("X title") +
ggtitle("Main title")
g
ggplotly(g)
As you can see, the Y axis title vanished.
Well, if ylim
is deleted it works, but I'd like to specify y limits.
I tried to do the following:
data(iris)
g = ggplot(data = iris, aes(x = Petal.Length, y = Petal.Width, fill = Species)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_manual(name = "legend", values = c("blue", "red", "green")) +
scale_y_continuous(name = "Y title", limits = c(0, 3)) +
xlab("X title") +
ggtitle("Main title")
g
ggplotly(g)
But now it's the legend title that doesn't fit.
My config : R 3.2.0, plotly 2.0.16, ggplot2 2.0.0
In both examples the graph given by ggplot is what I want, but ggplotly gives something else. Is it an issue, is there a workaround?
', '', 'just testing', ''))) – MLavoie Aug 18 '22 at 14:57