Home > Blockchain >  Can't show origin at (1,1) : R base graphics
Can't show origin at (1,1) : R base graphics

Time:08-02

I want to show the origin of the plot at (1,1) but can't do it with the following R code. I would add some line segments later to the plot.

xMax <- 600
yMax <- 150
plot(0, type = "n", 
    xlab = "XVal",
    ylab = "YVal",
    xlim = c(1, xMax), 
    ylim = c(1, yMax),
    xaxs="i", 
    yaxs="i"
)

enter image description here

CodePudding user response:

Simply add it using axis:

xMax <- 600
yMax <- 150
plot(0, type = "n", 
    xlab = "XVal",
    ylab = "YVal",
    xlim = c(1, xMax), 
    ylim = c(1, yMax),
    xaxs="i", 
    yaxs="i"
)
axis(1, at = 1)  ## add this
axis(2, at = 1)  ## add this

plot with origin at (1, 1)

  • Related