Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 839
J. Doe. Avatar asked Mar 21 '17 16:03

J. Doe.


People also ask

How do I suppress axis in R?

If you are going to create a custom axis, you should suppress the axis automatically generated by your high level plotting function. The option axes=FALSE suppresses both x and y axes. xaxt="n" and yaxt="n" suppress the x and y axis respectively.


1 Answers

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

like image 165
Axeman Avatar answered Nov 02 '22 00:11

Axeman