r - 当 ggrepel 不工作时,如何修复我的重叠标签?
问题描述
我正在做一个项目并尝试制作一些图形。我对编码很陌生,所以任何帮助将不胜感激。我创建了一个图表,但底部的标签是重叠的,所以我尝试在代码的不同位置自己添加 geom_text_repel() 和 geom_label_repel() 并且我不断收到错误消息:“FUN 中的错误(X [[ i]], ...) : 找不到对象'prop'”。我还尝试将 ggrepel 添加到 aes 层,但出现错误:“错误:stat_count 需要以下缺失的美学:x”。有没有人对如何让 ggrepel 使用我的代码或以其他方式使标签不重叠有任何想法?这是我的代码:
df %>%
filter(!is.na(`Self Reported Race (roll up)_Cleaned`)) %>%
ggplot() +
aes(
x = C19_Employment,
y = ..prop..,
group = `Self Reported Race (roll up)_Cleaned`,
fill = `Self Reported Race (roll up)_Cleaned`,
na.rm = TRUE
) +
labs(
title = "Employment Status by Self-Reported Race",
x = "Employment Status",
y = "Proportion of Race",
fill = "Self-Reported Race"
) +
geom_bar(position = "dodge", na.rm = TRUE) +
theme(legend.position = "bottom")
以及原始图的图像:(原始图
解决方案
推荐阅读
- angular - 在 Azure 中部署私有 npm 包
- tensorflow - 了解 TF 2.0 beta 中的图表
- spring-boot - 没有找到具有自定义 Jackson ObjectMapper 的类的描述
- netlify - Netlify:如果此文件夹上的更改部署到不同的存储库(?)
- sql - 将多行汇总为单行
- javascript - 尝试使用 Context API 时看到“渲染不是函数”
- python - 以 15 分钟的时间间隔创建新列
- kotlin - Spring rest docs 响应正文为空,无法记录响应
- javascript - Chart.js 中的堆叠组栏:我可以给每个堆叠组一个唯一的颜色吗?
- image - 发生异常。RangeError(RangeError(索引):无效值:有效值范围为空:0)