0
我正在嘗試爲格子的x軸定義標籤barchart
。我認爲我可以使用at= ...
,labels=...
加入barchart
代碼的比例部分,但是當我這樣做時,x軸上不會出現任何標籤。我正在使用R 3.1.0和Windows操作系統。帶有格子條形圖的x軸標籤
下面是數據
dput(newdata)
structure(list(Area = c(537L, 538L, 539L, 611L, 612L, 613L, 616L,
621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L, 611L, 612L,
613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L,
611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L,
538L, 539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L,
635L, 537L, 538L, 539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L,
626L, 631L, 635L, 537L, 538L, 539L, 611L, 612L, 613L, 616L, 621L,
622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L, 611L, 612L, 613L,
616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L, 611L,
612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L,
539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L,
537L, 538L, 539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L,
631L, 635L, 537L, 538L, 539L, 611L, 612L, 613L, 616L, 621L, 622L,
625L, 626L, 631L, 635L, 537L, 538L, 539L, 611L, 612L, 613L, 616L,
621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L, 611L, 612L,
613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L,
611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L,
538L, 539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L,
635L, 537L, 538L, 539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L,
626L, 631L, 635L, 537L, 538L, 539L, 611L, 612L, 613L, 616L, 621L,
622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L, 611L, 612L, 613L,
616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L, 539L, 611L,
612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L, 537L, 538L,
539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L, 631L, 635L,
537L, 538L, 539L, 611L, 612L, 613L, 616L, 621L, 622L, 625L, 626L,
631L, 635L), Year = c(1992L, 1992L, 1992L, 1992L, 1992L, 1992L,
1992L, 1992L, 1992L, 1992L, 1992L, 1992L, 1992L, 1993L, 1993L,
1993L, 1993L, 1993L, 1993L, 1993L, 1993L, 1993L, 1993L, 1993L,
1993L, 1993L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1995L, 1995L, 1995L,
1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L,
1995L, 1996L, 1996L, 1996L, 1996L, 1996L, 1996L, 1996L, 1996L,
1996L, 1996L, 1996L, 1996L, 1996L, 1997L, 1997L, 1997L, 1997L,
1997L, 1997L, 1997L, 1997L, 1997L, 1997L, 1997L, 1997L, 1997L,
1998L, 1998L, 1998L, 1998L, 1998L, 1998L, 1998L, 1998L, 1998L,
1998L, 1998L, 1998L, 1998L, 1999L, 1999L, 1999L, 1999L, 1999L,
1999L, 1999L, 1999L, 1999L, 1999L, 1999L, 1999L, 1999L, 2000L,
2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L, 2000L,
2000L, 2000L, 2000L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L,
2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2002L, 2002L,
2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L,
2002L, 2002L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L,
2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2004L, 2004L, 2004L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L,
2004L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L,
2005L, 2005L, 2005L, 2005L, 2005L, 2006L, 2006L, 2006L, 2006L,
2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L,
2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
2007L, 2007L, 2007L, 2007L, 2008L, 2008L, 2008L, 2008L, 2008L,
2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2009L,
2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L,
2009L, 2009L, 2009L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2011L, 2011L,
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2011L, 2011L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
2012L, 2012L, 2012L, 2012L, 2012L, 2012L), Metric_ton = c(916L,
228L, 217L, 117L, 404L, 237L, 532L, 1028L, 299L, 289L, 743L,
655L, 45L, 557L, 255L, 157L, 35L, 393L, 167L, 476L, 526L, 363L,
227L, 601L, 98L, 45L, 707L, 341L, 223L, 181L, 169L, 280L, 743L,
258L, 323L, 122L, 821L, 219L, 77L, 770L, 332L, 258L, 283L, 221L,
242L, 730L, 279L, 522L, 118L, 347L, 220L, 55L, 553L, 273L, 248L,
170L, 353L, 188L, 474L, 325L, 264L, 282L, 395L, 21L, 29L, 449L,
270L, 284L, 141L, 297L, 194L, 245L, 266L, 53L, 227L, 94L, 174L,
418L, 417L, 229L, 373L, 204L, 316L, 128L, 280L, 286L, 141L, 142L,
502L, 258L, 228L, 354L, 275L, 418L, 230L, 403L, 171L, 122L, 304L,
301L, 91L, 415L, 140L, 97L, 326L, 260L, 455L, 142L, 308L, 170L,
384L, 208L, 101L, 60L, 697L, 185L, 54L, 337L, 214L, 432L, 155L,
379L, 162L, 247L, 274L, 234L, 129L, 510L, 142L, 212L, 446L, 257L,
543L, 206L, 613L, 241L, 218L, 533L, 153L, 296L, 648L, 189L, 99L,
451L, 275L, 551L, 217L, 606L, 240L, 359L, 303L, 394L, 261L, 763L,
119L, 21L, 875L, 290L, 500L, 317L, 685L, 319L, 600L, 397L, 614L,
156L, 899L, 13L, 9L, 860L, 223L, 455L, 389L, 611L, 284L, 722L,
270L, 424L, 326L, 880L, 68L, 1L, 635L, 255L, 386L, 369L, 603L,
304L, 524L, 285L, 360L, 123L, 331L, 13L, 8L, 475L, 203L, 276L,
299L, 422L, 191L, 574L, 179L, 34L, 121L, 197L, 70L, 12L, 419L,
182L, 353L, 228L, 414L, 151L, 486L, 247L, 203L, 12L, 174L, 18L,
16L, 532L, 234L, 272L, 265L, 551L, 205L, 426L, 297L, 297L, 30L,
153L, 97L, 30L, 651L, 161L, 206L, 203L, 519L, 261L, 571L, 744L,
353L, 104L, 255L, 33L, 24L, 974L, 192L, 357L, 413L, 682L, 430L,
1205L, 309L, 443L, 269L, 387L, 45L, 17L, 886L, 138L, 271L, 250L,
534L, 560L, 851L, 814L, 357L, 83L, 331L, 37L, 41L)), row.names = c("537.1992",
"538.1992", "539.1992", "611.1992", "612.1992", "613.1992", "616.1992",
"621.1992", "622.1992", "625.1992", "626.1992", "631.1992", "635.1992",
"537.1993", "538.1993", "539.1993", "611.1993", "612.1993", "613.1993",
"616.1993", "621.1993", "622.1993", "625.1993", "626.1993", "631.1993",
"635.1993", "537.1994", "538.1994", "539.1994", "611.1994", "612.1994",
"613.1994", "616.1994", "621.1994", "622.1994", "625.1994", "626.1994",
"631.1994", "635.1994", "537.1995", "538.1995", "539.1995", "611.1995",
"612.1995", "613.1995", "616.1995", "621.1995", "622.1995", "625.1995",
"626.1995", "631.1995", "635.1995", "537.1996", "538.1996", "539.1996",
"611.1996", "612.1996", "613.1996", "616.1996", "621.1996", "622.1996",
"625.1996", "626.1996", "631.1996", "635.1996", "537.1997", "538.1997",
"539.1997", "611.1997", "612.1997", "613.1997", "616.1997", "621.1997",
"622.1997", "625.1997", "626.1997", "631.1997", "635.1997", "537.1998",
"538.1998", "539.1998", "611.1998", "612.1998", "613.1998", "616.1998",
"621.1998", "622.1998", "625.1998", "626.1998", "631.1998", "635.1998",
"537.1999", "538.1999", "539.1999", "611.1999", "612.1999", "613.1999",
"616.1999", "621.1999", "622.1999", "625.1999", "626.1999", "631.1999",
"635.1999", "537.2000", "538.2000", "539.2000", "611.2000", "612.2000",
"613.2000", "616.2000", "621.2000", "622.2000", "625.2000", "626.2000",
"631.2000", "635.2000", "537.2001", "538.2001", "539.2001", "611.2001",
"612.2001", "613.2001", "616.2001", "621.2001", "622.2001", "625.2001",
"626.2001", "631.2001", "635.2001", "537.2002", "538.2002", "539.2002",
"611.2002", "612.2002", "613.2002", "616.2002", "621.2002", "622.2002",
"625.2002", "626.2002", "631.2002", "635.2002", "537.2003", "538.2003",
"539.2003", "611.2003", "612.2003", "613.2003", "616.2003", "621.2003",
"622.2003", "625.2003", "626.2003", "631.2003", "635.2003", "537.2004",
"538.2004", "539.2004", "611.2004", "612.2004", "613.2004", "616.2004",
"621.2004", "622.2004", "625.2004", "626.2004", "631.2004", "635.2004",
"537.2005", "538.2005", "539.2005", "611.2005", "612.2005", "613.2005",
"616.2005", "621.2005", "622.2005", "625.2005", "626.2005", "631.2005",
"635.2005", "537.2006", "538.2006", "539.2006", "611.2006", "612.2006",
"613.2006", "616.2006", "621.2006", "622.2006", "625.2006", "626.2006",
"631.2006", "635.2006", "537.2007", "538.2007", "539.2007", "611.2007",
"612.2007", "613.2007", "616.2007", "621.2007", "622.2007", "625.2007",
"626.2007", "631.2007", "635.2007", "537.2008", "538.2008", "539.2008",
"611.2008", "612.2008", "613.2008", "616.2008", "621.2008", "622.2008",
"625.2008", "626.2008", "631.2008", "635.2008", "537.2009", "538.2009",
"539.2009", "611.2009", "612.2009", "613.2009", "616.2009", "621.2009",
"622.2009", "625.2009", "626.2009", "631.2009", "635.2009", "537.2010",
"538.2010", "539.2010", "611.2010", "612.2010", "613.2010", "616.2010",
"621.2010", "622.2010", "625.2010", "626.2010", "631.2010", "635.2010",
"537.2011", "538.2011", "539.2011", "611.2011", "612.2011", "613.2011",
"616.2011", "621.2011", "622.2011", "625.2011", "626.2011", "631.2011",
"635.2011", "537.2012", "538.2012", "539.2012", "611.2012", "612.2012",
"613.2012", "616.2012", "621.2012", "622.2012", "625.2012", "626.2012",
"631.2012", "635.2012"), .Names = c("Area", "Year", "Metric_ton"
), class = "data.frame", reshapeLong = structure(list(varying = list(
c("1992", "1993", "1994", "1995", "1996", "1997", "1998",
"1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006",
"2007", "2008", "2009", "2010", "2011", "2012")), v.names = "Metric_ton",
idvar = "Area", timevar = "Year"), .Names = c("varying",
"v.names", "idvar", "timevar")))
這裏是我的barchart
代碼和at
和label
代碼
#at
years<-seq(1992,2012,by=1)
#labels
labs<-c("1992"," ","1994"," ","1996"," ","1998"," ", "2000"," ","2002"," ","2004"," ","2006"," ","2008"," ","2010", " ","2012")
barchart(Metric_ton ~as.factor(Year)|as.factor(Area),data=newdata,
main=list("Commercial Landings (mt) by Statistical Area,1992 - 2012 \nStatistical Areas with > 300 mt for the time series",cex=.8),
scales=list(y=list(cex=0.6),x=list(at=years,labels=labs,
cex=.6,rot=45)),
ylab="Metric Tons",xlab="Statistical Area",
strip = strip.custom(bg="white" ,
strip.levels = T))
非常感謝您的幫助。 – user41509 2014-09-30 19:56:59