2014-02-15 91 views
1

我使用點陣用下面的代碼的面板:我怎樣才能顏色的點上stripplot在地塊

stripplot(locs~factor(rep(1,length(locs)))|dataset, 
        col=locs.col, 
        pch=19,cex=0.7, 
        jitter.data=T,factor=rep(rnorm(length(locs))), 
        amount=abs(rep(rnorm(length(locs))))*0.05) 

然而,這似乎是錯誤的密謀相比,現在我期望的那樣。如果我單獨繪製數據集中的因子,繪製的第二個和第三個繪圖分別根據我在組合格子圖中獲得的顏色而有所不同。

例如,第二個陰謀個別:

stripplot(locs[101:200]~factor(rep(1,length(locs[101:200])))|dataset[101:200], 
         col=locs.col[101:200], 
         pch=19,cex=0.7, 
         jitter.data=T,factor=rep(rnorm(length(locs[101:200]))), 
         amount=abs(rep(rnorm(length(locs[101:200]))))*0.05) 

不給我在第二個小組的情節相同。

我試着改變數據集值的順序,但這不起作用。

我已經把下面的數據。

locs=c(44L, 71L, 93L, 69L, 67L, 58L, 107L, 57L, 66L, 54L, 73L, 59L, 
43L, 65L, 64L, 60L, 45L, 83L, 79L, 85L, 83L, 73L, 66L, 64L, 43L, 
84L, 39L, 43L, 130L, 80L, 57L, 91L, 62L, 40L, 60L, 65L, 97L, 
47L, 83L, 44L, 120L, 95L, 44L, 51L, 68L, 44L, 74L, 72L, 55L, 
68L, 67L, 63L, 52L, 54L, 86L, 67L, 67L, 47L, 54L, 53L, 76L, 38L, 
67L, 66L, 71L, 52L, 69L, 46L, 71L, 64L, 43L, 56L, 69L, 69L, 94L, 
45L, 41L, 67L, 43L, 73L, 81L, 51L, 43L, 94L, 75L, 45L, 52L, 42L, 
93L, 44L, 44L, 80L, 45L, 68L, 41L, 101L, 66L, 64L, 45L, 52L, 
51L, 44L, 48L, 80L, 50L, 55L, 48L, 80L, 88L, 47L, 90L, 72L, 43L, 
54L, 96L, 54L, 45L, 76L, 59L, 45L, 75L, 53L, 46L, 95L, 43L, 112L, 
44L, 47L, 46L, 44L, 105L, 91L, 72L, 106L, 89L, 123L, 49L, 46L, 
70L, 81L, 41L, 100L, 85L, 48L, 54L, 85L, 46L, 140L, 94L, 47L, 
80L, 106L, 77L, 59L, 46L, 90L, 49L, 91L, 41L, 50L, 37L, 46L, 
47L, 81L, 33L, 60L, 49L, 49L, 47L, 47L, 59L, 48L, 67L, 45L, 77L, 
102L, 96L, 146L, 86L, 44L, 124L, 113L, 54L, 93L, 53L, 48L, 114L, 
72L, 47L, 46L, 56L, 86L, 89L, 49L, 47L, 45L, 46L, 55L, 101L, 
76L, 91L, 46L, 128L, 117L, 123L, 112L, 68L, 68L, 40L, 53L, 61L, 
42L, 43L, 66L, 34L, 50L, 43L, 88L, 111L, 93L, 39L, 120L, 33L, 
52L, 86L, 90L, 38L, 78L, 94L, 89L, 129L, 49L, 107L, 79L, 88L, 
67L, 42L, 34L, 119L, 43L, 65L, 90L, 45L, 95L, 94L, 74L, 112L, 
47L) 

dataset=structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 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, 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, 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, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("T1", 
"H2", "V6"), class = "factor") 

locs.col=c("darkblue", "yellow", "red", "yellow", "yellow", "yellow", 
"red", "yellow", "yellow", "yellow", "yellow", "yellow", 
"darkblue", "yellow", "yellow", "yellow", "darkblue", 
"yellow", "yellow", "yellow", "yellow", "red", "yellow", 
"yellow", "darkblue", "yellow", "darkblue", "darkblue", 
"red", "red", "yellow", "yellow", "yellow", "darkblue", 
"yellow", "yellow", "red", "yellow", "red", "darkblue", 
"red", "red", "darkblue", "darkblue", "yellow", "darkblue", 
"red", "yellow", "yellow", "yellow", "yellow", "yellow", 
"yellow", "yellow", "red", "yellow", "yellow", "yellow", 
"yellow", "yellow", "yellow", "darkblue", "yellow", 
"yellow", "yellow", "yellow", "yellow", "yellow", 
"yellow", "yellow", "darkblue", "yellow", "yellow", 
"yellow", "yellow", "darkblue", "darkblue", "yellow", 
"darkblue", "yellow", "yellow", "darkblue", "darkblue", 
"red", "yellow", "darkblue", "yellow", "darkblue", "yellow", 
"darkblue", "darkblue", "yellow", "darkblue", "red", "darkblue", 
"red", "yellow", "red", "darkblue", "darkblue", "darkblue", 
"darkblue", "darkblue", "yellow", "darkblue", "darkblue", 
"darkblue", "yellow", "yellow", "darkblue", "yellow", 
"yellow", "darkblue", "darkblue", "red", "darkblue", "darkblue", 
"yellow", "yellow", "darkblue", "yellow", "darkblue", 
"darkblue", "yellow", "darkblue", "red", "darkblue", "darkblue", 
"darkblue", "darkblue", "yellow", "red", "yellow", "red", 
"yellow", "red", "darkblue", "darkblue", "yellow", "yellow", 
"darkblue", "yellow", "yellow", "darkblue", "darkblue", 
"yellow", "darkblue", "red", "yellow", "darkblue", "yellow", 
"red", "yellow", "darkblue", "darkblue", "yellow", "darkblue", 
"yellow", "darkblue", "yellow", "darkblue", "darkblue", 
"darkblue", "yellow", "darkblue", "yellow", "darkblue", 
"darkblue", "darkblue", "darkblue", "darkblue", "darkblue", "yellow", 
"darkblue", "yellow", "yellow", "yellow", "red", "yellow", 
"darkblue", "red", "red", "darkblue", "yellow", "darkblue", 
"darkblue", "yellow", "yellow", "darkblue", "darkblue", 
"darkblue", "yellow", "yellow", "darkblue", "darkblue", 
"darkblue", "darkblue", "darkblue", "yellow", "yellow", 
"yellow", "darkblue", "red", "red", "red", "red", "yellow", 
"yellow", "darkblue", "yellow", "yellow", "darkblue", 
"darkblue", "yellow", "darkblue", "darkblue", "darkblue", 
"yellow", "red", "yellow", "darkblue", "red", "darkblue", 
"darkblue", "yellow", "yellow", "darkblue", "yellow", 
"yellow", "yellow", "red", "darkblue", "red", "yellow", 
"red", "darkblue", "darkblue", "darkblue", "yellow", "darkblue", 
"darkblue", "red", "darkblue", "yellow", "yellow", "yellow", 
"yellow", "darkblue") 

注:因爲我失去了我的帳戶資料,thie問題,我這裏張貼previously,我重新發布這個問題,管理員請隨時合併問題等

回答

1

所以我需要改變colgroups

stripplot(locs~factor(rep(1,length(locs)))|dataset, 
        groups=locs.col, 
        pch=19,cex=0.7, 
        jitter.data=T,factor=rep(rnorm(length(locs))), 
        amount=abs(rep(rnorm(length(locs))))*0.05)