[R] ggplot2 month and year boxplot x axis order problem
philipharrison
pharriso at uwaterloo.ca
Fri Jun 24 21:07:23 CEST 2011
Hi thanks for your patience, I understand what you mean now. I made some
dummy data;
x<-(structure(list(ID = c(1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L, 1734L,
1734L, 1734L, 1734L, 1734L), Temp = c(4.414, 4.1002, 3.9433,
4.414, 4.414, 4.414, 4.414, 4.414, 4.414, 4.414, 4.414, 4.414,
4.414, 4.414, 4.414, 4.414, 4.414, 4.414, 4.414, 4.414, 4.414,
4.414, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433,
3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433,
3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433, 3.9433,
11.6314, 11.6314, 11.6314, 11.6314, 11.6314, 11.6314, 11.6314,
11.6314, 11.6314, 11.4745, 11.4745, 11.4745, 11.4745, 11.6314,
11.6314, 11.7883, 12.1021, 12.5728, 13.3573, 13.5142, 14.1418,
15.0832, 11.1607, 11.1607, 11.1607, 11.1607, 11.3176, 11.3176,
11.3176, 11.9452, 11.7883, 11.7883, 11.7883, 11.9452, 12.4159,
12.5728, 13.3573, 13.3573, 13.3573, 13.0435, 12.8866, 12.8866,
12.8866, 12.8866, 12.8866, 12.8866, 12.8866, 12.8866, 12.8866,
12.8866, 12.8866, 12.8866, 12.8866, 12.8866, 12.8866, 12.8866,
11.0038, 11.0038, 11.0038, 11.0038, 11.0038, 11.0038, 11.0038,
11.0038, 10.8469, 10.8469, 10.8469, 10.8469, 10.8469, 10.8469,
10.8469, 10.8469, 9.121, 9.121, 9.121, 9.121, 9.121, 9.121, 9.121,
9.121, 5.0416, 5.0416, 5.0416, 5.0416, 5.0416, 5.0416, 5.0416,
5.0416, 5.0416, 5.0416, 3.3157, 3.3157, 3.3157, 3.3157, 3.1588,
3.1588, 3.1588, 3.1588, 1.5898, 1.7467, 1.7467, 1.7467, 1.7467,
1.7467, 0.8053, 0.8053, 0.8053, 0.8053, 0.8053, 0.8053, 0.8053,
0.8053, 0.8053, 0.8053, 2.845, 2.845, 2.845, 2.845, 2.845, 2.845,
2.845, 2.845, 2.845, 2.845, 2.845, 2.845, 2.845), Date.Time =
structure(c(2L,
2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L), .Label = c("02/11/2010",
"04/05/2010", "07/06/2010", "08/12/2010", "10/01/2011", "13/03/2011",
"15/02/2011", "15/07/2010", "19/08/2010", "20/04/2011", "20/08/2010",
"23/10/2010", "28/09/2010", "30/09/2010"), class = "factor"),
Month.Year = structure(c(5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("01,2011",
"02,2011", "03,2011", "04,2011", "05,2010", "06,2010", "07,2010",
"08,2010", "09,2010", "10,2010", "11,2010", "12,2010"), class =
"factor"),
Month = structure(c(9L, 9L, 9L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L,
4L, 4L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Apr",
"Aug", "Dec", "Feb", "Jan", "Jul", "Jun", "Mar", "May", "Nov",
"Oct", "Sep"), class = "factor"), Week = c(19L, 19L, 19L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 40L,
40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L,
40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L,
40L, 40L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L,
43L, 43L, 43L, 43L, 43L, 43L, 45L, 45L, 45L, 45L, 45L, 45L,
45L, 45L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L), Shortdate =
structure(c(2L,
2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L), .Label = c("02/11/2010", "04/05/2010",
"07/06/2010", "08/12/2010", "10/01/2011", "13/03/2011", "15/02/2011",
"15/07/2010", "19/08/2010", "20/04/2011", "20/08/2010", "23/10/2010",
"28/09/2010", "30/09/2010"), class = "factor")), .Names = c("ID",
"Temp", "Date.Time", "Month.Year", "Month", "Week", "Shortdate"
), class = "data.frame", row.names = c(NA, -172L))
Then my ggplot is:
plot1<-ggplot(data=x,aes(Month.Year,Temp))+
+ geom_boxplot()
and my months are do not appear in chronological order in my plot
Cheers
Phil
--
View this message in context: http://r.789695.n4.nabble.com/ggplot2-month-and-year-boxplot-x-axis-order-problem-tp3623029p3623342.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list