簡體   English   中英

在極限點上繪制X軸

[英]Plot X-axis on the extreme points

我正在使用帶有自定義軸標簽和字體的交互圖。 這是我正在使用的代碼:

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。如何解決此問題?

感謝@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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM