[英]edit legend values in ggplot2
我有如下圖所示。 它是使用以下命令創建的:
popanim <- ggplot(data = pop2, aes(
x = age1,
y = ifelse(gender == 1, -pop_rel, pop_rel),
fill = gender,
group = district
)) +
geom_col() +
# facet_wrap( ~ country) +
coord_flip() +
transition_states(district, transition_length = 2, state_length = 1) +
labs(title = 'district: {closest_state}')+
xlab("age") + ylab("population") #HERE
anim_pop <- animate(popanim, nframes = 50, renderer = gifski_renderer("gganimate.gif"))
anim_save(anim_pop = anim_pop, filename ="//pyramidd.gif")
現在我要做的下一件事是將圖例值從 1 修改為male
,將 2 修改為female
我試過scale_fill_discret
但它不起作用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.