0

I am working on some code where I have to plot MPG of all types of cars over several years. I am using geom="boxplot" in R and it returns the boxplots, but puts all the years as the axis values. I would like it to return all the boxplots, but only list every five years, i.e. 1985, 1990, 1995, etc.

Below is the following code that I am using:

qplot(factor(year), comb08, data=car, geom="boxplot", xlab="Year", ylab="MPG")

2
  • 2
    Can you post some part of car? Commented May 6, 2013 at 19:21
  • Otherwise, try scale_x_continuous(breaks=seq(Year[1],Year[length(Year)],by=5)) to set 5 year breaks Commented May 6, 2013 at 19:27

1 Answer 1

1
library(scales)
scale_x_date(breaks = "5 years", labels=date_format("%Y")) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.