简体   繁体   English

如何使用 R 中的带状图在水平方向上使用点函数?

[英]How to use the points function in the horizontal with a stripchart plot in R?

I am trying to get a stripchart with their medians in the horizontal.我想得到一个带中位数水平的条形图。 In the stripchart function there is a parameter that allows you to do that ( vertical=F ) but I cannot find a similar parameter to draw the medians in the horizontal using points .stripchart函数中,有一个参数允许您这样做( vertical=F ),但我找不到类似的参数使用points绘制水平中的中位数

My example:我的例子:

median <- tapply(mtcars$mpg, mtcars$gear, median)

stripchart(mpg ~ gear,
           data = mtcars, 
           main = "title",
           xlab = "x axis",
           ylab = "y axis",
           col = c('green', 'blue', 'purple'),
           pch = 16,
           cex = 0.8,
           method = 'jitter',
           vertical = F)
points(x=c(median), pch="--", cex=5)

This is what I am getting right now:这就是我现在得到的:

图 1

This is what I would like to have (but instead of in the vertical way, I want in the horizontal way).这就是我想要的(但不是垂直方式,我想要水平方式)。 [Same code than before but using vertical = F ]. [与以前相同的代码,但使用vertical = F ]。 图 2

Does anyone know how can I do it?有谁知道我该怎么做?

Thanks very much in advance首先十分感谢

Regards问候

Thanks to this post , I found the solution!感谢这篇文章,我找到了解决方案!

stripchart(mpg ~ gear,
           data = mtcars, 
           main = "title",
           xlab = "x axis",
           ylab = "y axis",
           col = c('green', 'blue', 'purple'),
           pch = 16,
           cex = 0.8,
           method = 'jitter',
           vertical = F)
points(c(median), order(median), pch="|", cex=2)

图片

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM