[英]Minor ticks not showing in ggplot2 (R)
I'd like my continuous y axis to have both labeled major ticks and minor unlabeled ticks. 我希望连续的y轴同时具有标记的主要刻度线和未标记的次要刻度线。 The reproducible code below should illustrate the problem. 下面的可复制代码应说明此问题。 It seems that the minor_breaks argument within scale_y_continuous is having no effect. 似乎scale_y_continuous中的minor_breaks参数无效。
data.data <- data.frame(Categorical=c("First", "Second", "Third", "Fourth"), Mean=c(25, 40, 90, 65))
ggplot(data=data.data, aes(Categorical, Mean)) +
geom_bar(stat="identity", fill="white", width=0.75, color="black") +
scale_y_continuous(breaks=seq(0,100,20), minor_breaks=seq(10,100,20), limits=c(0,100), expand=c(0,0)) +
theme(axis.title=element_text(size=12, face="italic"),
axis.text=element_text(size=12, face="plain"),
axis.line=element_line(color="black", size=0.5),
panel.grid.major.y=element_blank(),
panel.grid.minor.y=element_blank(),
panel.grid.major.x=element_blank(),
panel.grid.minor.x=element_blank(),
panel.background=element_blank())
Sorry, 抱歉,
I found the solution. 我找到了解决方案。 (There is no built-in code to do this, but by specifying the number of breaks and adding a labels argument you can create unlabeled ticks by labeling them "") (没有内置代码可以执行此操作,但是通过指定中断次数并添加labels参数,可以通过将未标记的刻度标记为“”来创建未标记的刻度。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.