【问题标题】:Plot X-axis on the extreme points在极值点上绘制 X 轴
【发布时间】:2018-03-30 22:29:00
【问题描述】:

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

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)

下面是图:

如您所见,X 轴线没有达到 1 和 11。我应该如何解决这个问题?

【问题讨论】:

  • 您可以添加box(bty = 'l')。你可以用axis(1, at = 1:11, las = 1, cex.axis=cex_axis)代替你的11行代码

标签: r


【解决方案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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多