【问题标题】:ggplotly deletes axis title in combination with scale_x_continuousggplotly 结合 scale_x_continuous 删除轴标题
【发布时间】:2016-04-11 13:09:18
【问题描述】:

ggplotly 命令有问题。

如果我用scale_x_continuous 缩放轴,它会删除xlabylab 文本。

library(plotly)
df <- data.frame(a=letters, b=LETTERS, x=runif(26), y=runif(26))
g <- ggplot(df, aes(x,y)) + 
  geom_point(aes(text=sprintf('letter: %s\nLetter: %s', a, b))) +
  xlab('test') + ylab('test') +
  scale_x_continuous(breaks=seq(-100,100,.1), minor_breaks=seq(-100,100,.05), limits=c(0,1))
g
(gg <- ggplotly(g))

g 图表在轴上的两个标签仍然可以,但如果我将scale 设置为任何轴,ggplotly 图表会删除标题。

这与轴无关。但是目前我没有检查过其他scales

知道为什么会发生这种情况以及如何解决吗?

【问题讨论】:

    标签: r ggplot2 plotly


    【解决方案1】:

    我不确定这是不是有意的,但如果您使用 scale_... 函数,那么您必须在 scale_... 内提供轴标题,因为在 labs()xlab()/ylab() 内设置的标题被忽略。

    g <- ggplot(df, aes(x,y)) + 
          geom_point(aes(text=sprintf('letter: %s\nLetter: %s', a, b))) +
          ylab('test') +
          scale_x_continuous("test",breaks=seq(-100,100,.1), 
                          minor_breaks=seq(-100,100,.05), limits=c(0,1))
    g
    (gg <- ggplotly(g))
    

    【讨论】:

      猜你喜欢
      • 2021-07-28
      • 2021-12-16
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      • 2012-11-20
      • 1970-01-01
      • 2018-01-31
      相关资源
      最近更新 更多