Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a plot using ggplot2 in which I'd like many ticks along the x-axis, yet only some of the ticks will have tick labels associated with them. However, I'd like the tick marks for those that have labels to be longer than those that don't.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
725 views
Welcome To Ask or Share your Answers For Others

1 Answer

In base R, you can suppress the x-axis with the initial plot call (with xaxt='n'), and then use tcl to control tick length (see ?par) with two axis(1, ...) calls.

plot(1:10, xaxt='n', ylab='', las=1)
axis(1, at=1:10, tcl=-0.8)
axis(1, at=seq(0, 11, 0.2), labels=NA)

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...