2012-08-17 62 views
2

我有10-15個條目,看起來像這樣一個data.frame:繪製多個變量:標註點

 group time1  time2 time3 
1  F18 4394.500 21043.50 14949.00 
2  F25 4678.000 23727.65 15683.12 
3  F30 4909.775 23487.60 16724.40 

我繪製這樣的:

plot(variable[,2:4]) 

使之與3情節出現time1,time2和time3的行和3行。

是否有可能用存儲在組(F18,F25 ...)中的值來標記數據點?

+1

看看了'ggplot2'包。它比使用基本R繪製好得多。 – 2012-08-17 13:49:02

+0

YOu可以使用'text()'。看到http://stackoverflow.com/questions/3453695/adding-text-to-a-plot – 2012-08-17 14:02:22

回答

1

我也推薦使用ggplot2(或點陣)。

但是,您可以

  • 使用text根據組

  • 使用顏色在給定位置顯示標籤文本(纔有意義,如果有相對較少的羣體相比,

  • 請注意plot (data.frame)實際上使用pairs

放在一起:

df <- data.frame (group = sample (LETTERS[1:3], 10, replace=TRUE), 
        x = rnorm (10), y = runif (10), z = rnorm (10)) 

panel.text <- function(x, y, text, ...) 
    text (x, y, labels = text) 

pairs (df[-1], text = df$group, lower.panel = panel.text, # label with name 
    pch = 20, col = as.numeric (df$group))    # label with color 

pairs panel function

+0

上帝該死的非常感謝你!我使用lower.panel和upper.panel與panel.text來顯示所有變量。 – Denise 2012-08-17 15:56:32