有谁知道如何在R中创建散点图,以便在PRISM的graphpad中创建类似于these的图:

我尝试使用箱形图,但它们不能以我想要的方式显示数据。这些由graphpad生成的柱状散点图为我更好地显示了数据。
如有任何建议,我们将不胜感激。
发布于 2012-09-13 16:00:44
正如@smillig提到的,你可以使用ggplot2来实现这一点。下面的代码重现了你非常好的警告之后的情节,这是相当棘手的。首先加载ggplot2包并生成一些数据:
library(ggplot2)
dd = data.frame(values=runif(21), type = c("Control", "Treated", "Treated + A"))接下来,更改默认主题:
theme_set(theme_bw())现在我们来构建这个图。
G= ggplot(dd,aes(type,values))
G=g+ geom_jitter(aes(pch=type),position=position_jitter(width=0.1))
G=g+fun.y=函数(I) colour="black")
G=g+ stat_summary( fun.ymax=function(i) mean(i) + qt(0.975,length(i))*sd(i)/length(i),fun.ymin=function(i) mean(i) - qt(0.975,length(i)) *sd(i)/length(i),geom="errorbar",作图
g

stat_summary动态计算所需的值。您还可以创建单独的数据框,并使用基数R的geom_errorbar和geom_bar.的回答
发布于 2012-09-13 15:36:12
如果您不介意使用ggplot2包,有一种简单的方法可以用geom_boxplot和geom_jitter制作类似的图形。使用mtcars示例数据:
library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot() + geom_jitter() + theme_bw()这将生成以下图形:

文档可在此处查看:http://had.co.nz/ggplot2/geom_boxplot.html
发布于 2021-04-11 20:11:49
我最近遇到了同样的问题,并找到了自己的解决方案,使用ggplot2。作为示例,我创建了chickwts数据集的一个子集。
library(ggplot2)
library(dplyr)
data(chickwts)
Dataset <- chickwts %>%
filter(feed == "sunflower" | feed == "soybean")由于在geom_dotplot()中无法将点改为符号,因此我按如下方式使用了geom_jitter():
Dataset %>%
ggplot(aes(feed, weight, fill = feed)) +
geom_jitter(aes(shape = feed, col = feed), size = 2.5, width = 0.1)+
stat_summary(fun = mean, geom = "crossbar", width = 0.7,
col = c("#9E0142","#3288BD")) +
scale_fill_manual(values = c("#9E0142","#3288BD")) +
scale_colour_manual(values = c("#9E0142","#3288BD")) +
theme_bw()这是最终的图:

更多细节,你可以看看这篇文章:
http://withheadintheclouds1.blogspot.com/2021/04/building-dot-plot-in-r-similar-to-those.html?m=1
https://stackoverflow.com/questions/12399506
复制相似问题