does anyone know how to remove the word "name_id" on the y-axis?
Here is the code:
library(lubridate)
fouryears <- # set start y-m-d
make_date(seq(year(min(presidential$start)),
year(max(presidential$end)),
by = 4),
1, 1)
library(forcats)
library(stringr)
presidential %>%
mutate( # create president name and seq.
id = 33 + row_number(),
name_id = fct_inorder(str_c(name, " (", id, ")"))) %>%
ggplot(aes(start, name_id, colour = party)) +
geom_point() +
geom_segment(aes(xend = end, yend = name_id)) + # draw duration line
scale_colour_manual("Party", # set color for party
values = c(Republican = "red", Democratic = "blue")) +
scale_y_discrete("name_id") + # not use label from 'aes' above
scale_x_date(NULL, # not use label from 'aes' above
breaks = presidential$start, # set break points
date_labels = "'%y", # show `yy for the year
minor_breaks = fouryears) + # tick every 4 years
ggtitle("Terms of US Presdients",
subtitle = "Roosevelth (34th) to Obama (44th)"
) +
theme(
panel.grid.minor = element_blank(),
axis.ticks.y = element_blank()
)
I assume it must be an argument in scale_y_discrete(). I tried "name", "label" but no success.