siddhu
siddhu

Reputation: 409

How to get customize the x-axis in ggplot2 package?

I am currently using the ggplot2 package to plot a quantity by each year and I want to make it so that only every other year shows up in the x-axis instead of every year, like it currently is. So how would I go about doing this in the ggplot2 package.

I am not sure how to show plots in stack overflow but my current plot has all the years from 1996 to 2011 right next to each other, but I only want to show every other year from 1996 so that all the tick marks are more spread apart from each other.

Upvotes: 0

Views: 197

Answers (1)

WaltS
WaltS

Reputation: 5530

You should include a relevant example with code in your question. However, making a few assumptions from your description, I'd guess that you might try using the scales package and including the following

library(scales)
scale_x_date(labels=date_format("%Y"), breaks=date_breaks("2 year")) 

with your ggplot statements.

Upvotes: 1

Related Questions