r - ggplot2 中的图例 - 使用因子标签
问题描述
我正在使用该interactions
包从我的回归中制作交互图。
figure6 <- interact_plot(sitc0.logit, pred = lnlaggdpp,
modx = inter_industry, interval = TRUE) +
scale_x_continuous(name = "Economic Size (ln GDP)", breaks=seq(4,16.1,1)) +
scale_y_continuous(name = "Probability of sanctions busting", breaks=seq(0,.5,.025)) +
theme(legend.title = element_blank()) +
labs(title="Marginal Effects of Intra- and Inter-Industry Trade, Agricultural Goods") +
geom_line(aes(colour = inter_industry))
这是我运行上面的代码时得到的:
我花了最后几个小时试图让图例正确显示。“0”和“1”是称为 的因子变量的值inter_industry
。与其将水平显示为数字,我希望它在“0”和“1”的情况下说“行业间”和“行业内”。
我觉得这一定很容易解决,但我一辈子都无法让它发挥作用!我有 9 个这样的图表要制作,所以如果我能正确显示它们会很好。提前感谢您的任何帮助!
解决方案
添加
scale_fill_discrete(name = "", labels = c("Inter-Industry", "Intra-Industry"))
推荐阅读
- ios - 运行 pod install 后 Development Pod 文件消失?
- mercurial - hgsubversion 失败并显示“没有名为 repo 的模块”
- javascript - multer:使用返回未定义的 node.js 将 Excel 文件上传到数据库
- mysql - 在简单的 SQL 查询中可能没有正确使用索引
- python - 如何在 python 中显示我的图像?
- java - 如何使用 JSOUP 获取第一个链接?
- r - 字典满了!使用 dplyr 的错误消息
- keyboard - 在 Andorid 11 中替换 WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
- python - 初学者。只是找不到错误。python导出到CSV
- kubernetes - 如何让 traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip 工作?