Reputation: 351
I want to remove horizontal grid lines but keep vertical ones. I also want to keep ticks on both x and y axis.
This is my code and what I tried so far:
df <- data.frame("prop" = c(102.73,260.65), "Name" = c("All Genes","RG Genes"))
p<-ggplot(data=df, aes(x=Name, y=prop,fill=Name)) +
geom_bar(stat="identity")+
labs(x="", y = "Proportion of cis EQTLs")+
scale_fill_brewer(palette="Greens") +
theme_minimal()+
theme(legend.position = "none",panel.grid.minor.y = element_blank())
p + annotate("text", x = 1.5, y = 280, label = "p = XXXXXX", size = 3.5) +
annotate("rect", xmin = 1, xmax = 2, ymin = 270, ymax =270, alpha=1,colour = "black")
Upvotes: 2
Views: 2508
Reputation: 148
You were 95% of the way there. The grid has two sets of lines--major and minor. You removed half of the horizontal grid (panel.grid.minor.y
). To remove the other half add panel.grid.major.y = element_blank()
. To add ticks to both the x and y axis add axis.ticks = element_line()
df <- data.frame("prop" = c(102.73,260.65), "Name" = c("All Genes","RG Genes"))
p <- ggplot(data = df, aes(x = Name, y = prop, fill = Name)) +
geom_bar(stat = "identity") +
labs(x = "", y = "Proportion of cis EQTLs") +
scale_fill_brewer(palette="Greens") +
theme_minimal() +
theme(legend.position = "none",
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
axis.line = element_line(),
axis.ticks = element_line())
p + annotate("text", x = 1.5, y = 280, label = "p = XXXXXX", size = 3.5) +
annotate("rect", xmin = 1, xmax = 2, ymin = 270, ymax =270, alpha=1,colour = "black")
Upvotes: 4