我正在使用r繪製50個狀態的barplot(分組),並且由於日期來自2005-2012,所以我想更改軸限制。這是代碼。圖形錯誤:使用r來更改軸限制
b<-read.csv("/Users/tori/Documents/Curry/breach 2.csv")
br<-data.frame(b$State,
e=b$Effective,
f=b$First)
View(br)
bb<-t(br[-1])
colnames(bb) <- br[, 1]
View(bb) #ok
bd<-data.frame(bb)
par(las=1,mar=c(3,9,1,1),cex.axis=0.55)
barplot(bb,beside=TRUE,horiz=TRUE,xlim=c(2004,2011))
結果是這樣,我真的很困惑。 (我不能更新圖片,但它似乎以外區域的限制仍然有曲線。
dput(head(bb)) structure(c(0L, 2006L, 2009L, 2006L, 2006L, 2005L, 2005L, 2005L, 2003L, 2005L, 2006L, 2005L, 2006L, 2005L, 2005L, 2005L, 2007L, 2005L, 2005L, 2005L, 2005L, 2005L, 2007L, 2005L, 2006L, 2005L, 2006L, 2005L, 2006L, 2005L, 2008L, 2005L, 2006L, 2006L, 0L, 2005L, 2006L, 2006L, 2006L, 2006L, 2008L, 2006L, 2007L, 2005L, 2007L, 2005L, 2006L, 2005L, 2011L, 2006L, 2009L, 2005L, 2006L, 2005L, 2006L, 2005L, 2005L, 2005L, 2007L, 2006L, 2006L, 2005L, 0L, 2006L, 2005L, 2005L, 2005L, 2005L, 2005L, 2008L, 2006L, 2005L, 2006L, 2005L, 2007L, 2005L, 2006L, 2005L, 0L, 2010L, 2006L, 2005L, 2009L, 2006L, 0L, 2007L, 2005L, 2005L, 2009L, 2005L, 2007L, 2005L, 2007L, 2005L, 2008L, 2005L, 2005L, 2005L, 2008L, 2006L, 2006L, 2005L, 2007L, 2009L), .Dim = c(2L, 52L), .Dimnames = list(c("e", "f" ), c("Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Puerto Rico", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming")))
請發表'dput(head(bb))',這樣我們就可以看到數據是什麼樣子以及它存儲在哪個類中,只需將其編輯到您的問題中 – Gregor
如果變量是Date或者一個因素變量,那麼你可能會錯誤地假設'xlim'的論點真的在做什麼。 –