I'm graphing data with ggplot and animating it using gganimate. I have colors as my labels and when I add a geom_label_repel() part to my graph it adds the labels but displays the colors as the color code. (Example Blue is displayed as #0000FFFF). Here is a snapshot of my animated graph.
My data is just cumulative percentages for m&m's colors in each bag. Here is what I currently have for my ggplot() and am wondering if I have something wrong or if there is a reason why it's changing the labels from color names to the number codes.
df<- data.frame(x=mm_data$Bag,
y= c(mm_data$totalp_red,mm_data$totalp_blue,
mm_data$totalp_orange,mm_data$totalp_yellow,
mm_data$totalp_brown,mm_data$totalp_green),
group = c(rep("Red", nrow(mm_data)),
rep("Blue", nrow(mm_data)),
rep("Orange", nrow(mm_data)),
rep("Yellow", nrow(mm_data)),
rep("Brown", nrow(mm_data)),
rep("Green", nrow(mm_data))))
group.colors <- c( "blue3","sandybrown","green3","darkorange"
,"red2","yellow")
ggplot(df, aes(x, y, group=group, color=group)) +
geom_line() +
geom_point() +
geom_label_repel(label= df$group,max.overlaps = Inf)+
scale_color_manual(values = group.colors)+
ggtitle("Colors present in my M&M Bag") +
ylab("Distribution percentage") +
xlab("Bags of M&M's")+
transition_reveal(x)```
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)