[R] About doing figures
lily li
chocold12 at gmail.com
Sun Jul 16 07:43:01 CEST 2017
Hi R users,
I still have the problem about plotting. I wanted to put the datasets on
one figure, x-axis represents values B, y-axis represents values C, while
different colors label column A. Each record uses a circle on the figure,
while hollow circles represent DF=1 and solid circles represent DF=2. I put
my code below, but the A labels do not correspond to the true record, so I
don't know what is the problem. Thanks for your help.
dfm
dfm1= subset(dfm, DF==1)
dfm2= subset(dfm, DF==2)
plot(c(15:30),seq(from=0,to=60,by=4),pch=19,col=NULL,xlab='Value
B',ylab='Value C')
Color = as.factor(dfm1$A)
colordist = grDevices::colors()[grep('gr(a|e)y', grDevices::colors(),
invert = T)] # for unique colors
Color.unq = sample(colordist,length(Color))
points(dfm1[,3],dfm1[,4],col=Color.unq,pch=1)
points(dfm2[,3],dfm2[,4],col=Color.unq,pch=19)
legend('bottom',as.character(Color.unq),col=Color.unq,lwd=rep(2,length(Color.unq)),cex=.6,ncol=5)
legend('bottom',as.character(Color),col=Color.unq,lwd=3,cex=.6,ncol=5,text.width=c(9.55,9.6,9.55))
dfm is the dataframe below.
DF A B C
1 65 21 54
1 66 23 55
1 54 24 56
1 44 23 53
1 67 22 52
1 66 21 50
1 45 20 51
1 56 19 57
1 40 25 58
1 39 24 53
2 65 25 52
2 66 20 50
2 54 21 48
2 44 30 49
2 67 27 50
2 66 20 30
2 45 25 56
2 56 14 51
2 40 29 48
2 39 29 23
[[alternative HTML version deleted]]
More information about the R-help
mailing list