在极值点绘制X轴

时间:2018-03-30 22:29:00

标签: r

我使用与自定义轴标签和字体的交互图。这是我使用的代码:

interaction.plot(
        targetData$block,
        targetData$condition,
        100*as.numeric(targetData$correct),
        las=1, 
        ylim=c(20,80),
        ylab="Percent Correct Identification(%)", 
        xlab="Block", 
        main=title,
        legend=FALSE,
        lwd=c(2,2,2,2),
        type="p",                
        axes=FALSE,     
        bty="n",
        xtick=FALSE,
        cex.lab=1.6,
        pch=c(15,18,17,20),
        cex=c(1.6,2.0,1.7,2.5),
        col=lineColors
        )

    cex_axis <- 1.5
    axis(1, labels=FALSE, cex.axis=cex_axis,tck=0)
    axis(2, labels=FALSE)
    # axis(1, at = c(0), labels = c(0), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(1), labels = c(1), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(2), labels = c(2), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(3), labels = c(3), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(4), labels = c(4), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(5), labels = c(5), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(6), labels = c(6), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(7), labels = c(7), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(8), labels = c(8), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(9), labels = c(9), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(10), labels = c(10), las = 1,  cex.axis=cex_axis)
    axis(1, at = c(11), labels = c(11), las = 1,  cex.axis=cex_axis)

以下是这个数字: enter image description here

正如您所看到的,X轴线未达到1和11.如何解决此问题?

1 个答案:

答案 0 :(得分:1)

感谢@rawr的评论,解决方案是:

interaction.plot(
        targetData$block,
        targetData$condition,
        100*as.numeric(targetData$correct),
        las=1, 
        ylim=c(20,80),
        ylab="Percent Correct Identification(%)", 
        xlab="Block", 
        main=title,
        legend=FALSE,
        lwd=c(2,2,2,2),
        type="p",                
        axes=FALSE,     
        bty="n",
        xtick=FALSE,
        cex.lab=1.6,
        pch=c(15,18,17,20),
        cex=c(1.6,2.0,1.7,2.5),
        col=lineColors
        )

    box(bty = 'l')
    cex_axis <- 1.5
    axis(1, labels=FALSE, cex.axis=cex_axis,tck=0)
    axis(2, labels=FALSE)
    axis(1, at = 1:11, las = 1, cex.axis=cex_axis)
    axis(2, at = seq(20,80,20), las = 1, cex.axis=cex_axis)
相关问题