guys I have used the code:
Combine_mean %>% ggplot(aes(x=factor(Year), y=Length, colour=gender, group=gender)) + geom_line()
Which has produce a comprehensive graph, x-axis is however cluttered, listing every year from 1674 to 1834. I would prefer to display this in 10 year increments, would I need to adjust my initial data frame and so the results for the lines for both male and female or could this be done through editing the code above.
This should alleviate the issue (I have used dummy data):
library(dplyr)
library(ggplot2)
#Data
Combine_mean <- data.frame(Year=c(seq(1674,1834),seq(1674,1834)),
gender=c(rep('female',161),rep('male',161)),
Length=c(cumsum(rnorm(161)),cumsum(rnorm(161))))
#Code
Combine_mean %>%
ggplot(aes(x=factor(Year), y=Length, colour=gender, group=gender)) +
geom_line()+
scale_x_discrete(limits=as.character(seq(1674,1834,by=10)))
Output:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.