I have the following table but after many tries have been unable to plot the data so that the x-axis tick marks line up with the year
. I have found solutions to boxplots, but not for geom_line()
How can I make discrete labels for year?
the following solutions did not work
g + scale_x_discrete(limits=c("2013","2014","2015"))
g + scale_x_discrete(labels=c("2013","2014","2015"))
distance_of_moves distance moved year 1 2.914961 2013 2 2.437516 2014 3 2.542500 2015
ggplot(data = distance_of_moves, aes(x = year, y = `distance moved`, group = 1)) + geom_line(color = "red", linetype = "dashed", size = 1.5) + geom_point(color = "red", size = 4, shape = 21, fill = "white") + ylab("Average distance of movement") + xlab("year")
as.factor(year)
in theaes()
year
column is numeric. You can either (a) convert the column to afactor
or (b) specify the breaks you want and continue using the continuous scale:+ scale_x_continuous(breaks = 2013:2015)
.