in Education by
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)

1 Answer

0 votes
by
Don't use df$ in your ggplot verbs when you are referring to the same data; You need aes(..), even in geom_label_repel. Try this. ggplot(df, aes(x, y, group=group, color=group)) + geom_line() + geom_point() + geom_label_repel(aes(label=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)

Related questions

0 votes
    I'm graphing data with ggplot and animating it using gganimate. I have colors as my labels and when I add a ... changing the labels from color names to the number codes. df...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I made the following plot in my Rmarkdown file, and render it using Xaringan. --- title: "myTitle ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    When I plot densities with ggplot, it seems to be very wrong around the limits. I see that geom_density ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    So I'm trying to make box and whisker plots for my weekly/monthly profit and loss for my sports betting picks for ... gotten me so far And following that here is my code exceldata...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I'm trying to use the Android GraphView library (http://www.android-graphview.org/), but no matter ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I am running the code and it works ggplot(data_df, aes(x= RR, y= PPW, col = year)) + ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Write the HTML code to get the line with 5 as thickness, length 50% and color as red Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    I'm trying to plot a geom_rect(). Why do I receive an Error in FUN(X[[i]], ...) : ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I have a list of ggplots of simple ggplot line graphs based on a location. I created a list of ggplot ... (rnaturalearthdata) library(dplyr) library(ggthemes) #create line plot x...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    ________ modify a ggplot or theme object by adding on new components. (a) +.gg (b) -.gg (c) /.gg ... Data Analysis of R Programming Select the correct answer from above options...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    Which of the following creates a new ggplot plot from a data frame? (a) qplot_ggplot (b) ggplot.data. ... Analysis of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    __________ create a complete ggplot appropriate to a particular data type. (a) autoplot (b) is.ggplot (c) ... of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    Suppose I have a ggplot with more than one legend. mov...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm trying to keep the legend of one layer (smooth) and remove the legend of the other (point). I have tried ... = gear)) + theme_bw() Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
...