Reputation: 5819
My example is taken from here (link). R version is 3.4.3, ggplot2 version is 2.2.1
library(tidyverse)
df <- data.frame(dose=c("D0.5", "D1", "D2"),
len=c(4.2, 10, 29.5))
ggplot(data=df, aes(x=dose, y=len)) +
geom_bar(stat="identity")
Almost every ggplot2 tutorial shows some simple graph. I always notice the major gridlines are about twice the thickness of the minor gridlines, which is what I'd expect. This is shown in the first image below. It looks great.
Whenever I plot something on ggplot the minor and major gridlines share the same weight, the same thickness, by default. Why? I didn't change any gridline settings? Is there some R Studio global setting I accidentaly enabled/disabled? I want the minor gridlines to be a lighter weight than the major gridlines, like the first image shown. The second image is what I get when I ggplot the graph.
Upvotes: 8
Views: 9318
Reputation: 1106
You can change the weight of the grid lines by using the theme function
df <- data.frame(dose=c("D0.5", "D1", "D2"),
len=c(4.2, 10, 29.5))
ggplot(data=df, aes(x=dose, y=len)) +
geom_bar(stat="identity") +
theme(panel.grid.minor = element_line(size = 0.5), panel.grid.major = element_line(size = 1))
Upvotes: 15