r - ggplot竖条配置文件
问题描述
给定数据,例如
df <- data.frame(Site="A",Depth=0:-20,comp=c(rep("sable",14),rep("gres",7)))
df <- rbind(df,data.frame(Site="B",Depth=0:-15,comp=c(rep("sable",3),rep("gres",13))))
我想绘制由 comp 着色的深度与站点。我尝试:
ggplot(data=df) +
geom_col(aes(Site, Depth,fill = comp)) + labs(y = "Depth (m)")
但是得到与我的数据不对应的y轴,为什么?任何修复?我也试过:
ggplot(data=df) +
geom_line(aes(Site, Depth,col = comp),size=8) + labs(y = "Depth (m)")
那里的 y 轴是正确的,但线段是不连续的,线条不允许我填充图案。我看过包 aqp,但不使用基于 ggplot 的绘图。任何帮助表示赞赏。
解决方案
推荐阅读
- mysql - 在 Windows 7 上安装 MySQL 5.5 时出错
- javascript - 当我更新页面时,如何让我的所有页面自动更新?
- sql - Teradata 递归 SQL 查找给定子表的父级的父级
- reactjs - 反应表单:输入数据不会显示
- php - Google Analytics API 数据检索中的 401 Login Required 错误
- c++ - inputMask 用空格填充 QLineEdit
- javascript - 在javascript中停止日期到纪元转换
- keycloak - Keycloak:从“编辑帐户”页面更新自定义用户属性
- python - spark XGBoostClassifier 包中是否有参数,例如 Python XGBoost fit() 函数中的“subsample_weight”?
- angular - 为什么在 for 循环中未定义使用 ngModel 的模板引用变量?