在(基本)R 中的镜像条形图上显示轴

Displaying the axes on mirror barplot in (basic) R

抱歉,如果这个问题很幼稚,但我被卡住了,无法在其他地方找到具体的答案。我是初学者。我无法在下面解释的图中显示垂直轴。

barplot(-(seq(0,10,2)), width=0.6, space=1, xlim=c(-12,12), ylim=c(2,10), horiz=T, axisnames=FALSE,col="green")
barplot(seq(0,10,2),add=T, width=0.6, space=1, axes=F,horiz=T,axisnames=FALSE,col="darkred")

当我尝试 "include the option axis.lty=1 to draw it"(引用自 statmethods.net)时,我收到警告说它是 "no graphical parameter"。请任何人启发我使用 boxplot() 来解决这个问题?提前致谢。

参见barplot的手册:

axisnames logical. If TRUE, and if there are names.arg (see above), the other axis is drawn (with lty = 0) and labeled.

axis.lty the graphics parameter lty applied to the axis and tick marks of the categorical (default horizontal) axis. Note that by default the axis is suppressed.

仅当 height 参数具有名称属性或您提供 names.arg 时才会绘制该轴。当满足这个条件时,将绘制一条空白轴线,您可以使用 axis.lty = 1 使其可见。请参见以下示例(水平轴与第一个条重叠,因为您将 ylim 设置为 c(2, 10)):

barplot(
    -(seq(0,10,2)), width=0.6, space=1, names.arg = paste('h=', -(seq(0,10,2))),
    xlim=c(-12,12), ylim=c(2,10),
    horiz=T, axisnames=T,col="green", axis.lty = 1, las = 1)

barplot(seq(0,10,2),add=T, width=0.6, space=1,
        axes=F,horiz=T,axisnames=FALSE,col="darkred", axis.lty = 1)