数据:
library(tidyverse)
library(lubridate)
library(plotly)
test <- tribble(
~Name, ~Date, ~Score, ~comp,
"Ken" , "3-2-2020" , 5, "PC1",
"Ken" , "3-2-2020" , 3, "PC1",
"Ken" , "3-2-2020" , 4, "PC1",
"Ken" , "3-2-2020" , 5, "PC1",
"Ken" , "3-3-2020" , 5, "PC1",
"Ken" , "3-3-2020" , 2, "PC1",
"Ken" , "3-4-2020" , 5, "PC1",
"Ken" , "3-5-2020" , 5, "PC1",
"Ken" , "3-6-2020" , 4, "PC1",
"Ken" , "3-2-2020" , 5, "PC2",
"Ken" , "3-2-2020" , 3, "PC2",
"Ken" , "3-2-2020" , 4, "PC2",
"Ken" , "3-2-2020" , 5, "PC2",
"Ken" , "3-3-2020" , 5, "PC2",
"Ken" , "3-3-2020" , 2, "PC2",
"Ken" , "3-4-2020" , 5, "PC2",
"Ken" , "3-5-2020" , 5, "PC2",
"Ken" , "3-6-2020" , 4, "PC2",
"Ken" , "7-6-2020", 4, "PC3"
) %>%
mutate(Date = lubridate::mdy(Date))
我想将其转换为多面的时间序列图,如下所示:
plot <- test %>%
ggplot(., aes(x=Date, y=Score)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
ylim(1,5.3) +
theme_bw() +
facet_wrap(. ~ comp)
plot
但是当我使用plotly时,它看起来像这样。
ggplotly(plot)
是什么问题? x轴看起来很奇怪