r - 使用 ggplot2 将平均值添加到 R 中的分组箱形图
问题描述
我在两种温度(27C 和 31C)及其密度下拥有三种藻类培养物(A、B、C)。我想制作一个箱形图,其中 x 轴为温度,y 轴为密度,每个温度以上的三种文化(见下图)。我还需要包含一个带有每个培养物和温度的平均密度的点。我的脚本仅在每个温度上方绘制一个平均值,但我需要的是 A@27C、B@27C、C@27 和 A@31C、B@31C 和 C@31C 的平均值。我试图调整一些有类似问题的脚本,但我无法让它工作。任何帮助将非常感激。
graph<-ggplot(Algae, aes(x = Temperature,
y = Density,
fill=Culture))+
geom_boxplot()+
stat_summary(fun=mean,
geom="point",
shape=20,
size=2,
color="red",
fill="red",
position = position_dodge2 (width = 0.5, preserve = "single"))
解决方案
推荐阅读
- r - 如何使用 R 根据共享元素对两个组进行排序?
- azure - Azure 策略 - 防止在没有身份验证的情况下创建应用服务
- html - 当我缩小屏幕时,某些列文本在 Td 元素内不可见
- vuetify.js - Vuetify:仅针对某些标签从右到左显示
- java - com.mysql.cj.jdbc.exceptions.CommunicationsException:GCP 中的通信链路故障 - CloudSQL
- javascript - 如何在 select 和 option html 标签上添加和删除自定义错误注释类?
- wpf - WPF CosmosDB ReadNextAsync() 在 background_worker 中调用时挂起
- python-3.x - 如何使用 TFDS 选择单个标签文件夹
- vue.js - jsPdf表 - 所有表列不可见
- c++ - c++是如何编译的?(关于变量声明)