为什么 R 不会在水平箱线图上过度绘制一个点,但会在垂直箱线图上绘制点?
Why won't R overplot a point on a horizontal boxplot, but will on a vertical boxplot?
我有 2 个箱线图,我还想在其中包含一个平均值点。看起来,当您将 horizontal=TRUE 作为参数时,points() 函数不再在箱线图上绘制点。
这是我的数据:
fired <- c(34,37,37,38,41,42,43,44,44,45,45,45,46,48,49,53,53,54,54,55,56)
对于垂直箱线图:
> boxplot(fired,
+ main = "Fired Boxplot",
+ col=(c("gold")))
> points(mean(fired), lwd=5, col="darkred", pch=22)
但是对于水平箱线图(相同的数据和函数,只有一个参数改变):
> boxplot(fired,
+ horizontal=TRUE,
+ main = "Fired Boxplot",
+ col=(c("gold")))
> points(mean(fired), lwd=5, col="darkred", pch=22)
没意义:
为什么它不绘制 horizontal=TRUE 情况下的点?它只是轴上的一个值。
如果您在 points
函数中指定 y=1
,它会起作用。
boxplot(fired,
horizontal=TRUE,
main = "Fired Boxplot",
col=(c("gold")))
points(mean(fired),1, lwd=5, col="darkred", pch=22)
我有 2 个箱线图,我还想在其中包含一个平均值点。看起来,当您将 horizontal=TRUE 作为参数时,points() 函数不再在箱线图上绘制点。
这是我的数据:
fired <- c(34,37,37,38,41,42,43,44,44,45,45,45,46,48,49,53,53,54,54,55,56)
对于垂直箱线图:
> boxplot(fired,
+ main = "Fired Boxplot",
+ col=(c("gold")))
> points(mean(fired), lwd=5, col="darkred", pch=22)
但是对于水平箱线图(相同的数据和函数,只有一个参数改变):
> boxplot(fired,
+ horizontal=TRUE,
+ main = "Fired Boxplot",
+ col=(c("gold")))
> points(mean(fired), lwd=5, col="darkred", pch=22)
没意义:
为什么它不绘制 horizontal=TRUE 情况下的点?它只是轴上的一个值。
如果您在 points
函数中指定 y=1
,它会起作用。
boxplot(fired,
horizontal=TRUE,
main = "Fired Boxplot",
col=(c("gold")))
points(mean(fired),1, lwd=5, col="darkred", pch=22)