2021年1月24日星期日

geom_dumbell spacing, legends in different places, and multiple aesthetics (timelines)

I saw this interesting way of creating a publication timeline using geom_dumbell, so I created my own by first loading the libraries:

library(tidyverse)  library(rio)  library(ggalt)  library(ggrepel)  

Entering in some data:

# create data frame  df <- data.frame(    paper = c("Paper 1", "Paper 1", "Paper 2", "Paper 2", "Paper 3", "Paper 3", "Paper 3", "Paper 3"),     round = c("first","revision","first","revision","first","first","first","first"),    submission_date = c("2019-05-23","2020-12-11", "2020-08-12","2020-10-28","2020-12-10","2020-12-11","2021-01-20","2021-01-22"),    journal_type = c("physics", "physics","physics","physics","chemistry","chemistry","chemistry","chemistry"),    journal = c("journal 1", "journal 1", "journal 2", "journal 2", "journal 3", "journal 4", "journal 5", "journal 6"),    status = c("Revise and Resubmit", "Waiting for Decision", "Revise and Resubmit", "Accepted", "Desk Reject","Desk Reject", "Desk Reject","Waiting for Decision"),    decision_date = c("2019-09-29", "2021-01-24", "2020-08-27", "2020-10-29", "2020-12-10","2021-01-05","2021-01-22","2021-01-24"),    step_complete = c("yes","no","yes","yes","yes","yes","yes", "no"),    duration_days = c(129,44,15,1,0,25,2,2)    # convert variables to dates  df$decision_date = as.Date(df$decision_date)  df$submission_date = as.Date(df$submission_date)  

and, finally, creating my own basic timeline using this code:

ggplot(df, aes(x = submission_date, xend = decision_date,                       y = paper, label = duration_days,                       color = status)) +     geom_dumbbell(size = 1, size_x = 1) +     scale_color_manual(values=c("green", "red", "darkolivegreen4", "turquoise1")) +    labs(x=NULL, color = 'Status:',         y=NULL,          title="Timeline of Journal Submissions",          subtitle="Start date, decision date, and wait time (in days) for my papers.") +    #theme_ipsum_tw() +     ggrepel::geom_label_repel(nudge_y = -.25, show.legend = FALSE) +     theme(legend.position = 'top') + NULL  

What I have thus far

As you can see from the above image, I can't see the x-axis. Additionally, I'd like to put another aesthetic and legend on the right side for the journal, perhaps putting a different shape on each line. Any other bells and whistles using the above data would be fun, too. Thanks!

https://stackoverflow.com/questions/65875675/geom-dumbell-spacing-legends-in-different-places-and-multiple-aesthetics-time January 25, 2021 at 04:36AM

没有评论:

发表评论