2017-09-03 1 views
0

x 축에 표시해야하는 모든 날짜를 가져올 수 없습니다. 날짜는 1996-2017 년에 걸쳐 있지만 2000-2015 년을 표시하기 위해서만 R을 얻을 수 있습니다. 나는 R에 상당히 익숙하다. 비슷한 질문에 대한 다른 대답은별로 도움이되지 않는다.x 축에 모든 요소 추가, R

breaks <- seq(1996,2017,1) 
with(gamePlot, hist(gamePlot$Date, breaks, 
         las=2, 
         col=rainbow(20), 
         xlim=c(1996,2017), 
         cex.axis=0.6, 
         xlab="Year Released", 
         main="Frequency of top rated games by year")) 

enter image description here

답변

0

를 추가해보십시오 plot=TRUE 옵션 1

with(gamePlot, hist(gamePlot$Date, breaks, 
         las=2, 
         col=rainbow(20), 
         xlim=c(1996,2017), 
         plot=TRUE, 
         cex.axis=0.6, 
         xlab="Year Released", 
         main="Frequency of top rated games by year")) 
0

hist에 (권장) :가 당신의 ggplot에 + scale_x_date(date_labels = "", date_breaks = "")을 한 후, as.Date()와 날짜 개체 날짜 열을 변환 사용 인수는 date_labels 또는 date_breaks입니다. See this for reference.

옵션 2 : 정수 벡터와 같은 날짜 열 (현재 상황)을 유지하려면, 당신은 휴식을 지정 + scale_x_discrete(limits = c(date1, date2, date3 ...) 인수 limits를 사용할 수 있습니다. 이 작업을 수행하려면 해당 int 열을 factor()의 인수로 변환해야 할 수 있습니다. See this for reference.

관련 문제