r - 使用 position_dodge() 的问题
问题描述
在使用颜色和形状时,我遇到了 position_dodge 的问题。
我想绘制一个实验的结果,在该实验中,在许多站点复制了两种治疗方法,并且我想以图形方式强调某些数据点。
由于 x 轴是一个因素,我使用 position_dodge 来分隔处理。到目前为止一切顺利,请参见下图 1。
但是,如果我想通过更改形状来强调特定数据点,请参见图 2。数据点现在已分为三列,而不是两列。
关于如何制作图表的任何建议,如下面的第三个面板所示。
site <- rep(c("site1"),times=6)
treatment <- rep(c("one","two"),times=2,each=3)
set.seed(21)
response <- c(rnorm(3,mean=4),
rnorm(3,mean=5))
special <- as.factor(c(0,1,0,0,0,0))
mydata <- data.frame(site,treatment,response,special)
#graph 1
ggplot()+
geom_point(data=mydata,
aes(x = site,
y = response,
colour=treatment),
size=4,
position=position_dodge(1))
#graph 2
ggplot()+
geom_point(data=mydata,
aes(x = site,
y = response,
colour=treatment,
shape=special),
size=4,
position=position_dodge(0.5))
解决方案
推荐阅读
- typescript - TypeScript 泛型:不满足约束
- arrays - 在多个工作表上求和多个值(在不同位置)
- r-plotly - 在 `geom_boxplot()` 和 plotly 中更改晶须长度
- javascript - Vuejs & Vuetify:有没有办法用来自 vuetify 的数据表循环模板(使用 v-slot 动态)?
- postsharp - PostSharp 错误 - 项目以或引用不受支持的平台:.NETPlatform,Version=v5.0
- twitter-bootstrap - 引导从桌面到移动的字段重组
- selenium - 通过 PSEXEC 执行 Selenium Ruby 测试
- java - 如何将用户输入存储在整数数组中?
- javascript - 使用 request.value 的错误请求
- typescript - 如何将 S3 中的图像下载为文件 Typescript