ggplot2: Have shorter tick marks for tick marks without labels

前端 未结 3 1795
醉梦人生
醉梦人生 2020-12-06 01:50

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 tic

3条回答
  •  半阙折子戏
    2020-12-06 02:30

    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

提交回复
热议问题