我试图改变与颜色相关的图例标题和标签。我尝试使用this答案作为指南,但它似乎对传奇文本没有影响。我认为这是因为我使用了一个因素,还是因为我使用了一个职位闪避?脚本和结果如下:
ggplot(ggplot_survey, aes(factor(hurricanes), fill = factor(bldg_flooding))) +
geom_bar(position = position_dodge2(width = 0.9, preserve = "single")) +
facet_wrap(facets = vars(C0_time)) +
scale_color_discrete(labels=c("No", "Yes", "No Response")) +
labs(title = "Would frequent flooding (building) prompt you to install WCS?",
color = "Response",
x = "Reported Hurricane Exposure",
y = "Count"
)

基本上,我希望上面的文字是“响应”,0是“否”,1是“是”,NA是“没有回应”。关于我哪里出错有什么建议吗?
发布于 2022-01-19 01:37:45
Per @silentdevildoll的回复:
ggplot(ggplot_survey, aes(factor(hurricanes), fill = factor(bldg_flooding))) +
geom_bar(position = position_dodge2(width = 0.9, preserve = "single")) +
facet_wrap(facets = vars(C0_time)) +
scale_fill_discrete(labels=c("No", "Yes", "No Response")) +
labs(title = "Would frequent flooding (building) prompt you to install WCS?",
fill = "Response",
x = "Reported Hurricane Exposure",
y = "Count"
)关键是替换scale_color_discrete (现在的scale_fill_discrete)和labs()位中的颜色。再次感谢!
https://stackoverflow.com/questions/70764030
复制相似问题