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.
On value axes, major grid lines are drawn for every major axis division. Minor grid lines separate the units delineated by major grid lines. Minor grid lines, which can only appear on value axes, appear for every minor axis division. By default, major grid lines appear for value axes.
Minor gridlines are horizontal and vertical lines that run through your chart layout to represent axis divisions. They are very useful for quickly calculating the height or breadth of visual components used in our chart.
To remove a particular panel grid, use element_blank() for the corresponding theme argument. For example to remove the major grid lines for the x axis, use this: p + theme(panel. grid.
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With