2

I am making a graph in ggplot, and have rotated my x-axis labels 80 degrees. However, this caused my x-axis labels to no longer align with my x-axis tick marks (labels are a little too far to the right of tick marks). Can anyone help me shift x axis labels to the left? I have tried hjust and vjust, but both seem to make my axis labels move up and down rather than side to side...

The head of my data frame (called Data) looks like this:

Date                       Well   Elev
1    2002-05-23            MW-3 929.04
2    2002-05-29            MW-3 929.39
3    2002-05-31            MW-3 929.37
4    2002-06-05            MW-3 929.36
5    2002-06-12            MW-3     NA
6    2002-06-13            MW-3 929.47
7    2002-06-19            MW-3 929.42
8    2002-06-26            MW-3 930.02
9    2002-07-05            MW-3 930.00

And my code looks like this:

ggplot(data= Data, aes(x = Date, y = Elev, group = Well, colour = Well)) +
geom_line(size = 0.75) +
  xlab("") + ylab("Elevation (ft.)") +
  scale_color_brewer(palette = "Spectral") +
  scale_x_date(breaks = date_breaks("1 year"),
           date_labels = ("%b %Y")) +
  theme(axis.text.x = element_text(angle = 80, hjust = 1),
        panel.grid.major.x = element_blank(),
        panel.grid.major.y = element_line( size=.1, color="gray"),
        panel.grid.minor = element_blank(), 
        axis.line.x = element_line(color = "black"),
        axis.line.y = element_line(color = "black"),
        panel.background = element_rect(fill = "white")) 
snalven
  • 411
  • 1
  • 6
  • 12
  • Did you look at this ? http://stackoverflow.com/questions/7263849/what-do-hjust-and-vjust-do-when-making-a-plot-using-ggplot – bVa Feb 01 '17 at 13:11
  • Hi bVa, thanks, yes I did see that post, but it says that hjust moves things horizontally, which it was not doing in my case, it was only moving things vertically... However, in reading the post again, I decided to try rotating my x-axis labels 90 degrees instead of 80 degrees. I'm not sure why this made the difference, but now when I set hjust to 0.5 and vjust to 0.5, the axes labels are where I want them. – snalven Feb 01 '17 at 22:39

0 Answers0