I have a data which contains 2 different years, and I would like to do a ggplot putting in the x-axis the number of the weeks, but I'm not able because when I get the labels right with function scale_x_discrete, the lines moves.
wk_dt <- dt %>%
filter((Description4=="SWF DULCE CHOCOLATE" | Description4=="SWF DULCE FRUTA PASION"| Description4=="SWF DULCE DULCE DE LECHE" | Description4=="MINI BROWNIE" | Description4=="BIZCOCHO ZANAHORIA" | Description4=="BIZCOCHO NARANJA-CHOCO")
& IsMenuItem == NoMenu
& wk_t > wk_current) %>%
group_by(wk_t, Description4)%>%
summarize(Uds = sum(UNIDADES))%>%
mutate(Uds_per = Uds / sum(Uds))%>%
ggplot(aes(x=wk_t, y=Uds, color=Description4))+
geom_line(size =2)+
geom_point(size = 3) + # CON LOS PUNTOS SE PUEDE VER EL ARTÍCULO NUEVO ESTA SEMANA
theme_minimal() +
labs(y = NULL ,x= "Semana del año") +
ggtitle("UDS. SUELTAS POR SEMANA") +
theme(legend.position = 'top',
legend.title = element_blank(),
legend.text = element_text(size=14),
legend.key.size = unit(1, 'cm'),
plot.title = element_text(size = 22, family = "serif", hjust = 0.5),
axis.text = element_text(size = 15),
axis.title.x = element_text(size = 17),
legend.title.align = 0.5) +
scale_x_discrete(limits = factor(c(seq(7,52,by=1),seq(1,6,by=1)))) +
scale_y_continuous(breaks = seq(0,6000, by = 1000)) +
guides(colour = guide_legend(nrow = 2,byrow= TRUE)) +
scale_color_manual(values = c("darkseagreen","orange","chocolate", "saddlebrown","moccasin","violet"))