plot - R: Suppress ticks and labels at endpoints of axis -


i have code producing below pasted plot

x <- c(2, 3, 4) y <- c(2.5, 4.1, 5.5)  plot(x, y, type = "o", xlim = c(1, 5), ylim = c(2, 6), axes = false, bty = "n") axis(side = 1, @ = seq(1, 5, 1)) axis(side = 2, @ = seq(2, 6, 1), las = 2) 

the plot looks this

i have neither ticks nor labels @ position 1 , 5, axis should still drawn. looking for: the plot should this

when using labels = c("", 2, 3, 4, "") ticks drawn. when using tick = false, no axis. have solution this?

you need draw line manually. using line2user function in this answer:

x <- c(2, 3, 4) y <- c(2.5, 4.1, 5.5)  plot(x, y, type = "o", xlim = c(1, 5), ylim = c(2, 6), axes = false, bty = "n") axis(side = 1, @ = 2:4)  lines(x = c(1, 5), y = rep(line2user(0, side = 1), 2), xpd = true) axis(side = 2, @ = seq(2, 6, 1), las = 2) 

enter image description here

note, line2user function gives position of lines in user coordinate system. need xpd = true draw outside plotting region.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -