2012-04-03 81 views
1

卓悅的所有彙總,標註在箱線圖散點圖點和箱線圖中的曲線圖中的R

我需要幫助找到一個解決方案來標註在箱線圖散點圖。

如下圖所示,有兩個數據,第一個是所有宏觀數據,第二個是每個宏觀數據的平均值。

TAB1 //查詢結果

 1  2  3  4  5  6 
1 13.2089 13.3161 13.2497 13.2268 13.2209 11.6036 
2 13.2923 13.3869 13.2950 13.2876 13.2922 11.7044 
3 13.4493 13.5394 13.4450 13.4735 13.4689 11.9483 

意味着
1 15.43801 15.38659 15.23252 15.50707 15.67684 15.25383

我的問題是,如何顯示在每個點上的標籤圖二。我想用他們的no.macrocosme標記每個點。

這是我的一點代碼:

#Macrocosme 
Mac = svalue(cbMacro) 

#Add boxplots to all Macs 
par(mfrow = c(1, 2)) 
boxplot(Tab1, main="Temperature of Macrocosme", xlab="No. Macrocosme", ylab="Temperature in Celcius", col=(c("gold","darkgreen")),ylim=range(c(min(vmin),max(vmax)))) 
points(1:length(Mac), means,pch = 22) 

#Add boxplots to a median of all Macs 
boxplot(means, main="Mean Temperature of all the Macrocosme", xlab="Mean", ylab="Temperature in Celcius") 
with(Tab1, stripchart(means, method="jitter", vertical=TRUE, add=TRUE, col="red",pch = 20)) 

我與功能文本()嘗試 - >顯示包textxy(在箱線圖不是在散點圖的數量,) - >沒有顯示任何東西

我估計有一個問題,當我確定x,y值..嗯..是否有可能,我們顯示圖中每個boxplot的總結(中位數,Q1 -Q3)?

這是我生成的圖表: 正如您在下面看到的,有兩個圖表,右側是所有大觀框的平均值框圖,左側框圖是散點圖意味着宏觀世界。

My Graph with boxplot and mean of all boxplot with 1-D scatterplot 之前感謝您的幫助..

問候,

Yougyz

回答

1

TEXT函數應該工作找到。例如,

R> x = rnorm(10) 
R> boxplot(x, ylim=c(-3, 3)) 
R> text(1, 1, "Hi", col=2) 

在你的榜樣,你可以試試:

text(1, means, LETTERS[length(means)], col=2) 

這應該顯示在紅點字母。但是,在您呼叫條形圖功能時,您已經「抖動」或「擺動」了點。既然你只有幾點,不要抖動他們(可能省略方法參數),並且以下應該工作:

text(1.3, means, LETTERS[length(means)], col=2)