Adding minor tick marks to the x axis in ggplot2 (with no labels)

匿名 (未验证) 提交于 2019-12-03 02:28:01

问题:

Below is example code of a plot that does almost exactly what I want. The only thing I want to add is tick marks on the x axis (same size as the major ticks) according to the minor_breaks defined below.

df 

Thanks in advance, --JT

回答1:

This would do it in the precise instance:

scale_x_continuous(breaks= seq(1900,2000,by=10),                    labels = c(1900, rep("",4), 1950, rep("",4), 2000),                    limits = c(1900,2000), expand = c(0,0)) + 

Here's a function that is not bullet-proof but works to insert blank labels when the beginning and ending major labels are aligned with the start and stopping values for the at argument:

insert_minor 

Test:

p 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!