控制y轴上的主要和次要网格线 [英] Controlling both the major and minor grid lines on the y axis
本文介绍了控制y轴上的主要和次要网格线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ch1 < - c(1:100)$ b $< qplot(x,y)
ch2 < - ch1 +
theme(panel.grid.minor = element_line(color =white,size = 0.5))+
scale_y_continuous(minor_breaks = seq(0,100,5))
ch2
我正在用ggplot并可以控制y轴次网格线。
但是我还需要做些什么才能控制y轴的主要网格线,所以它们不会自动设置(例如,以10s为单位,所以线条和y单位标签为10,20,30等)?
我尝试过 major_breaks = seq(0,100,10)
,但它不起作用。
感谢您的帮助。
解决方案
这只是休息
:
$ b
ch1 + theme(panel.grid.minor = element_line(color =white,size = 0.5))+
scale_y_continuous(minor_breaks = seq(0,100,5),breaks = seq(0,100,10)))
library(ggplot2)
x <- c(1:100)
y <- c(1:100)
ch1 <- qplot(x, y)
ch2 <- ch1 +
theme(panel.grid.minor = element_line(colour = "white", size = 0.5)) +
scale_y_continuous(minor_breaks = seq(0, 100, 5))
ch2
I am making a chart with ggplot and can control the y axis minor grid lines.
But what do I have to do to contol the y axis major grid lines as well so they are not set automatically (for example in units of 10s, so lines and y unit labels at 10,20,30 etc)?
I tried major_breaks = seq(0 , 100, 10)
but it did not work.
Thank you for your help.
解决方案
It's just breaks
:
ch1 + theme(panel.grid.minor = element_line(colour="white", size=0.5)) +
scale_y_continuous(minor_breaks = seq(0 , 100, 5), breaks = seq(0, 100, 10)))
这篇关于控制y轴上的主要和次要网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文