首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编辑图例(文本)标签与aes(因素)或可能的位置道奇

编辑图例(文本)标签与aes(因素)或可能的位置道奇
EN

Stack Overflow用户
提问于 2022-01-19 00:36:41
回答 1查看 159关注 0票数 0

我试图改变与颜色相关的图例标题和标签。我尝试使用this答案作为指南,但它似乎对传奇文本没有影响。我认为这是因为我使用了一个因素,还是因为我使用了一个职位闪避?脚本和结果如下:

代码语言:javascript
复制
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是“没有回应”。关于我哪里出错有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-19 01:37:45

Per @silentdevildoll的回复:

代码语言:javascript
复制
    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()位中的颜色。再次感谢!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70764030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档