Search code examples
rplotaxis-labels

R Base Plot suppress axis line but show ticks


I am having the following issue with the axis() function.

 axis(1,
       at=1:length(stringi::stri_rand_strings(21, 15)),
       labels=stringi::stri_rand_strings(21, 15),
       tick=1,
       lwd=1,
       mgp = c(0,1,0),
       col = title_colour,
       col.ticks = title_colour
       ,lty = "solid",
       cex.axis = 1,las=2,cex=0.75)

enter image description here

But whatI really need are the tickmarks without the continuous x'x line connecting the ticks:

enter image description here

How do I accomplish this using axis()??


Solution

  • Set col to NA but col.ticks to a value:

    plot(1, type = 'n', axes = FALSE)
    axis(1, c(0.75, 1, 1.25), col = NA, col.ticks = 1)
    

    enter image description here

    (Note my reproducible and minimal example, try to include that in your question!)