您好,有一個問題,March在我的圖中出現了兩次,但在我的數據中沒有出現。使用ggplot2月份顯示不正確
我的數據看起來像。我的數據框叫做try1。
Month Year tcol
2016-01-01 00:00:00 06 1461.0
2016-02-01 00:00:00 06 259.5
2016-03-01 00:00:00 06 191.2
2016-04-01 01:00:00 06 151.5
2016-05-01 01:00:00 06 119.6
2016-06-01 01:00:00 06 1372.5
2016-07-01 01:00:00 06 954.0
2016-08-01 01:00:00 06 1784.0
2016-09-01 01:00:00 06 1369.0
2016-10-01 01:00:00 06 6077.0
2016-11-01 00:00:00 06 1638.0
2016-12-01 00:00:00 06 3308.0
而我的代碼看起來像。
ggplot(try1, aes(Month,tcol)) +
geom_point(aes(colour = Year),size=2) +
geom_line(aes(colour = Year), size=0.73)+
theme_bw()+
guides(col = guide_legend(ncol = 2))+
scale_x_datetime(
breaks=date_breaks("1 months"),
labels=date_format("%B"))+
xlab("")+ #x axis label
ylab("Total Coliforms")
問題是,當我繪製我的圖形三月出現兩次。十月似乎被排除在外。
感謝您的幫助。
什麼數據類型是Month列?因素還是約會? – Wietze314
我無法重現該問題。你可以運行'dput(try1)'並將結果複製到你的問題中。那我們將使用相同類別的對象。 – Benjamin
@ 9Heads,您的月份標籤已關閉1個月;他們從十二月開始到十一月結束)。不太清楚你是如何做到的。 :) – Benjamin