p*****o 发帖数: 543 | 1 when i use pairs to plot the scatter plot, i used "col= " option to
differentiate 4 different groups. but in the output picture, how can i ask R
to write the legend of each color on it, indicating which color reflects
which group.
thank you so much | p*****o 发帖数: 543 | 2 thanks a lot but actually i didnt quite get it. Actually following is the
statement i wrote in R to create the plot. But i wish to have description
for each color in the picture.
pairs(Data_Matrix[,2:7],pch=22,col=Data_Matrix[,8])
R create the color automatically for me and I even dont know which color indicates each group (but sure, i can check that in the data set, but just wondering whether there is a way to do that automatically in R)
Thanks a lot | w*****n 发帖数: 375 | 3 col=Data_Matrix[,8] is equivalent to col = as.factor(Data_Matrix[,8])
you can use
pairs(Data_Matrix[,2:7],pch=22,col= c("black", "green", "red", "blue"))
indicates each group (but sure, i can check that in the data set, but just
wondering whether there is a way to do that automatically in R)
【在 p*****o 的大作中提到】 : thanks a lot but actually i didnt quite get it. Actually following is the : statement i wrote in R to create the plot. But i wish to have description : for each color in the picture. : pairs(Data_Matrix[,2:7],pch=22,col=Data_Matrix[,8]) : R create the color automatically for me and I even dont know which color indicates each group (but sure, i can check that in the data set, but just wondering whether there is a way to do that automatically in R) : Thanks a lot
| p*****o 发帖数: 543 | 4 actually I tried and then use the legend statement:
legend(0.1,0.1,legend=c('Cluster1','Cluster2','Cluster3'), col=c("yellow","
green","red"))
but still didnt see the legend...not sure where I messed it up...
【在 w*****n 的大作中提到】 : col=Data_Matrix[,8] is equivalent to col = as.factor(Data_Matrix[,8]) : you can use : pairs(Data_Matrix[,2:7],pch=22,col= c("black", "green", "red", "blue")) : : indicates each group (but sure, i can check that in the data set, but just : wondering whether there is a way to do that automatically in R)
| w*****n 发帖数: 375 | 5 panel.tt <- function(x, y, labels, cex, font, ...)
{
legend(median(x), median(x), c('Cluster1','Cluster2','Cluster3'),
col=c("yellow","green","red"),
pch = c(1))
}
pairs(mm[1:3, 2:4], diag.panel = panel.tt, col = c("yellow","green","red") )
【在 p*****o 的大作中提到】 : actually I tried and then use the legend statement: : legend(0.1,0.1,legend=c('Cluster1','Cluster2','Cluster3'), col=c("yellow"," : green","red")) : but still didnt see the legend...not sure where I messed it up...
|
|