ggplot2(R)中未显示小刻度 [英] Minor ticks not showing in ggplot2 (R)
本文介绍了ggplot2(R)中未显示小刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望连续的y轴同时具有标记的主要刻度线和未标记的次要刻度线.下面的可复制代码应说明此问题.似乎scale_y_continuous中的minor_breaks参数无效.
I'd like my continuous y axis to have both labeled major ticks and minor unlabeled ticks. The reproducible code below should illustrate the problem. It seems that the minor_breaks argument within scale_y_continuous is having no effect.
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())
推荐答案
对不起,
我找到了解决方案.(没有内置代码可以执行此操作,但是通过指定中断次数并添加标签参数,您可以通过将未打标的标签标记为"来创建未打标的标签)
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 "")
这篇关于ggplot2(R)中未显示小刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文