Sam
Sam

Reputation: 131

how to make major grid line y=0 black and all the other ones grey in ggplot2

I'm using ggplot2 in R to make an x-y graph and I was wondering how I can make the grid line y=0 to be black, while leaving the other grid lines grey

here is what I have so far

ggplot(data = subset(data, org %in% c('T','P','TP','PP')), mapping=aes(x=AA, y=v, color=org))+
  geom_point()+
  stat_smooth(method='lm', formula = y~log(x), se=FALSE)+
  scale_y_continuous( name=expression(paste('%',Delta,V)))+
  coord_cartesian(ylim = c(0.01, -0.035))+ 
  scale_x_continuous(name='#A')+
  ggtitle('Changes in Volume')+
  theme(plot.title = element_text(hjust = 0.5),
        axis.line.x = element_line(color="black", size = 2),
        panel.grid.major = element_line(color = "grey"), 
        panel.grid.minor = element_line(color = "grey"),
        panel.background = element_rect(colour = "black", size=4, fill=NA))

I would like to emphasize the fact that some of my data is above the y=0 and the other part is below.

thanks

Upvotes: 1

Views: 2995

Answers (1)

Sam
Sam

Reputation: 131

 + geom_hline(yintercept = 0, color = "black")

Upvotes: 1

Related Questions