- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 ggplot 在 R 中绘制我的数据,不显示错误栏 mustache 。为什么不显示 mustache ?如何解决才能显示它们?
(虽然没有必要在 geom_errorbar 中指定“data=...”,但我使用较小的数据集在较大的数据集之上绘制了几个点及其误差条。我在这里进行了简化只对所有内容使用较小的数据框,但想让这个示例接近我打算使用的代码。)
谢谢!肖娜
shapes <- c(1, 19, 15, 1, 0)
names(shapes) <- levels(smallDF$Treatment)
p <- ggplot(data=smallDF, aes(x=pNew, y=diff, group=Treatment))
p <- p + geom_errorbar(data=smallDF, aes(ymin=diff-se,ymax=diff+se),
color="black", width=.3, position=position_dodge(.5))
p <- p + geom_line(size=.3)
p <- p + geom_point(data=smallDF, aes(shape=Treatment),fill="white",
size=2.5)
#p <- p + scale_shape_manual(values=c(1, 19, 15, 1, 0))
p <- p + scale_shape_manual(values=shapes)
p <- p + xlab("Pressure (mmHg)") + ylab("delD (mm)")
p <- p + theme_bw()
p <- p + theme(
legend.position="none"
# , axis.text.y=element_blank()
# , axis.title.y=element_blank()
, panel.border=element_blank()
, axis.line = element_line(colour = "black")
, axis.text.x = element_text(size=10)
, axis.text.y = element_text(size=10)
, axis.title.x= element_text(size=10)
, axis.title.y= element_text(size=10)
, strip.text.x = element_text(size = 10)
)
p
Treatment step N diff sd se ci predictD pNew
cntl 2 7 0.256537749 0.130605763 0.049364339 0.120790185 1.483185156 10
cntl 3 7 0.317586245 0.151444256 0.057240549 0.140062577 1.626590815 15
cntl 4 7 0.377309785 0.165262839 0.062463482 0.152842634 1.788401781 20
cntl 5 7 0.433531627 0.173735352 0.065665791 0.160678402 1.964393744 25
cntl 6 7 0.467529177 0.171603123 0.064859884 0.158706419 2.142879696 30
cntl 7 7 0.441401156 0.163740786 0.0618882 0.15143497 2.291729181 35
cntl 8 7 0.360578168 0.143967074 0.054414439 0.133147337 2.402152991 40
cntl 9 7 0.263484929 0.117425017 0.044382485 0.108600028 2.481824239 45
cntl 10 7 0.172079736 0.094209661 0.035607905 0.087129405 2.53504158 50
cntl 11 7 0.081780331 0.070316765 0.026577239 0.065032161 2.561500546 55
cntl 12 7 0.172079736 0.094209661 0.035607905 0.087129405 2.53504158 50
cntl 13 7 0.263484929 0.117425017 0.044382485 0.108600028 2.481824239 45
cntl 14 7 0.360578168 0.143967074 0.054414439 0.133147337 2.402152991 40
cntl 15 7 0.441401156 0.163740786 0.0618882 0.15143497 2.291729181 35
cntl 16 7 0.467529177 0.171603123 0.064859884 0.158706419 2.142879696 30
cntl 17 7 0.433531627 0.173735352 0.065665791 0.160678402 1.964393744 25
cntl 18 7 0.377309785 0.165262839 0.062463482 0.152842634 1.788401781 20
cntl 19 7 0.317586245 0.151444256 0.057240549 0.140062577 1.626590815 15
cntl 20 7 0.256537749 0.130605763 0.049364339 0.120790185 1.483185156 10
3hpx 2 6 0.124643574 0.068765439 0.028073373 0.072164903 1.511618688 10
3hpx 3 8 0.121806932 0.088542241 0.03130441 0.074023166 1.537544183 15
3hpx 4 8 0.138107729 0.097228081 0.034375318 0.08128471 1.602344034 20
3hpx 5 8 0.149529 0.10158369 0.035915258 0.08492609 1.665227481 25
3hpx 6 8 0.157687817 0.101898303 0.036026491 0.085189113 1.724788023 30
3hpx 7 8 0.154261671 0.099724849 0.035258058 0.08337206 1.776475381 35
3hpx 8 8 0.140631071 0.091483297 0.03234423 0.07648195 1.819131367 40
3hpx 9 8 0.123241311 0.083112381 0.029384664 0.069483689 1.854326249 45
3hpx 10 8 0.103092334 0.075467614 0.026681831 0.063092504 1.882440312 50
3hpx 11 8 0.080332775 0.070303352 0.024855989 0.058775073 1.903587298 55
3hpx 12 8 0.103092334 0.075467614 0.026681831 0.063092504 1.882440312 50
3hpx 13 8 0.123241311 0.083112381 0.029384664 0.069483689 1.854326249 45
3hpx 14 8 0.140631071 0.091483297 0.03234423 0.07648195 1.819131367 40
3hpx 15 8 0.154261671 0.099724849 0.035258058 0.08337206 1.776475381 35
3hpx 16 8 0.157687817 0.101898303 0.036026491 0.085189113 1.724788023 30
3hpx 17 8 0.149529 0.10158369 0.035915258 0.08492609 1.665227481 25
3hpx 18 8 0.138107729 0.097228081 0.034375318 0.08128471 1.602344034 20
3hpx 19 8 0.121806932 0.088542241 0.03130441 0.074023166 1.537544183 15
3hpx 20 6 0.124643574 0.068765439 0.028073373 0.072164903 1.511618688 10
最佳答案
我将您的 width = 0.3
更改为 width = 5
。我还删除了您拥有的所有冗余 data = smallDF
,并将您单独设置的字体大小替换为 theme_bw()
的 base_size
参数。
p <- ggplot(data = smallDF, aes(x = pNew, y = diff, group = Treatment)) +
geom_errorbar(aes(ymin = diff - se, ymax = diff + se),
color = "black",
width = 5, ## This is the width of the crossbars!
position = position_dodge(.5))
geom_line(size = .3)
geom_point(aes(shape = Treatment),
fill = "white", size = 2.5) +
scale_shape_manual(values = shapes) +
xlab("Pressure (mmHg)") +
ylab("delD (mm)") +
theme_bw(base_size = 10) +
theme(
legend.position="none"
, panel.border=element_blank()
, axis.line = element_line(colour = "black")
)
p
关于R ggplot geom_errorbar 不显示 mustache ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36578083/
我想在我的 geom_bar 图上绘制误差线。我知道您可以调整 aes(ymax, ymin) 以仅显示上条或下条。 但是,我有一些负平均值和正平均值,我想分别显示误差线。 这里有一些示例代码和数据可
我的数据看起来像这样: df1 <- structure( list( y = c(-0.19, 0.3,-0.05, 0.15,-0.05, 0.15), lb
在下面的示例中,我有一个简单的平均值图,其中 X 轴和 Y 轴均带有标准差误差条。我想控制误差条宽度,以便两个轴始终绘制相同的尺寸。 理想情况下,我希望条形宽度/高度与符号大小相同(即在本例中 cex
使用 ggplot 在 R 中绘制我的数据,不显示错误栏 mustache 。为什么不显示 mustache ?如何解决才能显示它们? (虽然没有必要在 geom_errorbar 中指定“data=
我是 R 新手,并且 ggplot 和以下数据集(从较大的集合中选择作为代表)存在问题,其中 geom_errorbar 条与平均点不对齐(使用 geom_point),并且在某些情况下,水平条不与垂
我似乎无法重新生成之前使用下面的代码生成的绘图(使用ggplot2)。我现在收到错误消息“没有名为 StatHline 的统计数据”。有替代品吗? data <- data.frame( Corr
我有以下示例图: test <- data.frame("Factor" = as.factor(c("O", "C", "A")), b = c(0.1
我如何将误差线放置在适当颜色条的中心? df1 <- data.frame( supp = c("OJ","OJ","OJ","VC","VC","VC"), dose = c(0.5,1,2
我正在使用 ggplot 创建一个图形,并希望使用箭头来指示我的误差线超出定义轴的位置。例如,我想最终得到一个如下所示的图形: 我希望 R 确定哪些下限超出了定义的图表范围,并添加一个漂亮的箭头(而不
我正在尝试制作带有误差线的分组条形图。但是,我无法让误差条看起来正确(即比主条更细)和正确定位(在条的中心)。 position选项和 position_dodge()似乎无法正常工作,我无法弄清楚为
我有一个使用 ggplot 的绘图,我想在其中添加点和误差线。我正在使用 geom_errorbar 和 geom_point,但我收到一个错误:“离散值提供给连续比例”,我不知道为什么。下图中的数据
我正在尝试使用 ggplot 和 geom_errorbar 创建一个分面图。但是,每个不同的方面可能具有截然不同的 x 范围,因此误差条的宽度看起来并不“好”。这是一个 MWE: library(g
我有一个数据集,其中在不同的日子对不同的群体进行测量。 我想要并排的条形表示不同组在不同日期的测量值,条形组根据测量日间隔开,误差条覆盖在它们上。 我在躲避 geom_bar 时遇到问题同意 geom
我有一些数据,其中一些估计有很大的误差线。我想通过对图表设置限制来以有意义的比例绘制。但是,我还想指出错误栏超出限制的位置。最好使用箭头,如果可能的话,不使用 geom_segment,因为它似乎不能
我正在使用 ggplot2 生成一个相对于整数值预测变量的相当简单的比例图。我正在使用 geom_errorbar 来显示每个点估计的不确定性。 例如 require(ggplot2) mydata
我是一名优秀的程序员,十分优秀!