r - 使用 dotplot (binaxis = "y") 绘图时出现 x 轴错误 - ggplot
问题描述
你能帮我理解为什么我的 x 轴看起来很奇怪并帮助我解决这个问题吗?
解决方案
也许您正在考虑使用 geom_point 而不是 geom_dotplot ?您的轴是离散的,因为您使用了一个因子变量,但实际上您在右侧有一个空白区域。也许您可以代替使用两个数据集,在一个数据集上执行 ggplot 并使用您创建的颜色变量为正确的点着色。
storeProfit = storeProfit %>%mutate(color = (min(totalProfit) == totalProfit | max(totalProfit) == totalProfit))
ggplot(data = storeProfit, aes(x = factor(STORE), y = totalProfit,fill=color)) +
geom_dotplot(binaxis = "y", fill = "light blue")+
labs(title = "Total softdrink profit per Store", x = "Store", y = "Total Profit (USD$)") +
theme(axis.text.x=element_text(angle=90,hjust=1))+
scale_fill_manual(c("light blue","red"))
这是我能想到的最好的,没有可重复的数据集
推荐阅读
- reactjs - 赛普拉斯中的测试日期选择器
- excel - 从 VB.NET 写入 Excel 单元格
- python - python中的入口和循环
- vb.net - 在 .NET Core 中运行 VB.NET Web 服务
- python - 从 Pandas 中的两列中删除匹配值
- node.js - 在 monorepo 中,是否可以将包配置为“如果可以使用未编译的代码”?
- android - 如何在android studio的jetpack compose预览功能中启用点击预览?
- firebase - Firebase Appcheck 和 RecaptchaV3 提供程序
- node.js - 从相邻目录运行 NPM 脚本但保留当前工作目录
- java - 如何计算递归函数中的组合?