I have integrated my ggplot code into ggplotly but the scale_manual_color() for renaming the legend texts isn't recognised by ggplotly.
ggplotly(
ggplot(data = national2,aes(x=period, y=pregnancy))+
geom_line(aes(color=type),size=0.8)+
scale_color_manual(values=c("red","blue","green"),
breaks = c("pregnancy1019","pregnancy1519","pregnancy1014"),
labels=c("Teen pregnancy (10-19years)","Teen pregnancy (15-19years)","Teen pregnancy (10-14years)"))+
labs(
title = "Teen pregnancy trends from 2016Q1 to 2020Q2",
x="Yearly quarters",
y="Teen pregnancies"
)+
scale_x_yearqtr(n=10)+
theme_gray()+
theme(
plot.title = element_text(size = 14),
legend.title = element_blank(),
legend.text = element_text(size = 12),
axis.title = element_text(face = "bold",size = 11),
axis.text = element_text(face = "bold",size = 10)
)
)