0

I create the ggplot below with title and subitle but when I diplay it using ggplotly() the subtitle is lost.

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)
firmo23
  • 7,490
  • 2
  • 38
  • 114

1 Answers1

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>')))

This works let me know if it fixes your issue

PesKchan
  • 868
  • 6
  • 14