【问题标题】:Plot subtitle is lost when plot is diplayed with ggplotly()使用 ggplotly() 显示绘图时,绘图字幕丢失
【发布时间】:2021-11-03 11:47:44
【问题描述】:

我用标题和副标题创建了下面的 ggplot,但是当我使用 ggplotly() 显示它时,副标题丢失了。

library(ggplot2)
p <- ggplot(ToothGrowth, aes(x = factor(dose), y = len)) + 
  geom_boxplot()
library(plotly)
p <- p + labs(title = "Effect of Vitamin C on Tooth Growth",
              subtitle = "Plot of length by dose",
              caption = "Data source: ToothGrowth")
ggplotly(p)

【问题讨论】:

    标签: r ggplot2 ggplotly


    【解决方案1】:
    library(ggplot2)
    p <- ggplot(ToothGrowth, aes(x = factor(dose), y = len)) + 
      geom_boxplot()
    library(plotly)
    p <- p + labs(title = "Effect of Vitamin C on Tooth Growth",
                  subtitle = "Plot of length by dose",
                  caption = "Data source: ToothGrowth")
    ggplotly(p)%>% 
      layout(title = list(text = paste0('Effect of Vitamin C on Tooth Growth"',
                                        '<br>',
                                        '<sup>',
                                        'Plot of length by dose','</sup>')))
    

    如果它解决了您的问题,请告诉我

    【讨论】:

      猜你喜欢
      • 2020-09-14
      • 1970-01-01
      • 2020-05-06
      • 2020-10-30
      • 2017-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多