小编pri*_*se6的帖子

ggplot2 + plotly:轴标题消失

我一直在使用的时候有一个问题,ggplotly()一个ggplot图:y轴消失.这是一个使用iris数据集的可重现的例子(这个例子非常简单,但无论如何)

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)
Run Code Online (Sandbox Code Playgroud)

如您所见,Y轴标题消失了.

好吧,如果ylim删除它可行,但我想指定y限制.

我试着做以下事情:

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 …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 plotly ggplotly r-plotly

7
推荐指数
1
解决办法
2153
查看次数

标签 统计

ggplot2 ×1

ggplotly ×1

plotly ×1

r ×1

r-plotly ×1