我正在尝试创建一个在同一条线上有3种颜色的图,基于"Recorte column“,你可以在下面的示例中查看它:
Legenda `Hora da publica??~ Alcance `Curtidas e rea~ Comentários Compartilhament~ Resultados
<chr> <dttm> <dbl> <dbl> <dbl> <dbl> <lgl>
1 "Lucielle Lauren~ 2020-10-13 05:49:48 93 0 0 0 NA
2 "Lucielle Lauren~ 2020-10-13 05:57:12 2827 164 10 0 NA
3 "Assista agora a~ 2020-10-13 15:34:43 2641 68 1 0 NA
4 "Acompanhe agora~ 2020-10-23 09:07:32 3063 65 1 0 NA
5 "\U0001f535 Esta~ 2020-11-12 16:29:55 4578 105 17 0 NA
6 "Em respeito ao ~ 2020-10-23 16:48:41 4891 227 17 6 NA
这是我想要用来在3个不同标签中设置线的子集的列,代表图所演示的时间线中的3个阶段。
> head(campanhalutudo$Recorte)
[1] "Periodo 1" "Periodo 1" "Periodo 1" "Periodo 2" "Periodo 3" "Periodo 2"
这行代码会生成基图,而不会尝试对该行进行任何子集
`graflutudo <- ggplot(campanhalutudo, aes(x = `Hora da publica??o`, y = Alcance), label = "periodo") +
geom_line(color = "Purple") +
geom_line(aes(y = mean(Alcance)), color = "red", linetype = "dotted") +
scale_y_continuous(breaks = seq(0, 85000, by = 10000)) +
scale_x_datetime(labels = date_format("%m-%d"),
date_breaks = "4 days") +
theme_light()`
?
?
我已经尝试使用以下代码为线条添加颜色:
graflutudo<- ggplot(campanhalutudo, aes(x=`Hora da publica??o`, y = Alcance, factor= (Recorte)), label = "periodo") +
geom_line(color = "Purple") +
geom_line(aes(y = mean(Alcance)), color = "red", linetype = "dotted") +
scale_x_datetime(labels = date_format("%m-%d"),
date_breaks = "4 days") +
scale_y_continuous(breaks = seq(0, 85000, by = 10000)) +
theme_light()
它返回相同的图形,除了已经使用的紫色外,没有任何其他颜色。
我也在想,也许这不是在时间线中展示3个不同时间段的最好方式,类似于线下的条形图也可以做到这一点,任何提示都是受欢迎的。
转载请注明出处:http://www.jxbyjx.net/article/20230525/2552049.html