Reputation: 19
R noob here, my data set has a numerical variable called agegrp and it ranges from 1-7.
I'm trying to plot a histogram using the following code
ggplot(data, aes(x=agegrp)) + geom_histogram(colour="black", binwidth = 0.5)
But the x-axis only contains 2, 4, 6. What do I add/ change so that it shows 1-7?
Upvotes: 1
Views: 54
Reputation: 39595
Try with this:
#Code
ggplot(data, aes(x=agegrp)) +
geom_histogram(colour="black", binwidth = 0.5)+
scale_x_continuous(breaks=seq(1,7,by=1))
Upvotes: 1