11
votes

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()??

1
use lwd and lwd.ticks: axis(1, lwd = 0, lwd.ticks = 1) - rawr
That's the one I used. Please add it as an answer. - J. Doe.

1 Answers

13
votes

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!)