Dear useRs, I have the following data "z" of two variables "x"(z[,1]) and "y"(z[,2]).> dput(z)structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 4.36222673881464, 3.69969030080286, 4.2171385106796, 3.13216766340978, 4.48272959444564, 5.15902588302327, 5.48017158746089, 4.27937198622481, 6.87798628712867, 10.6244257045475, 4.28697206373731, 2.36185506591713, 3.8999910824793, 3.53659639173799, 3.55002661079475, 1.69933515030185, 3.05902585757021, 7.36381894775327, 7.40245656365444, 3.6848569064997, 6.08996204878611, 6.28326065486612, 3.94011667392145, 4.32959623927668, 4.53659549630782, 10.5471767576564, 3.25988629354992, 4.09457312472741, 3.80883550148271, 3.31050022622877, 4.97298874506525, 4.44111508385058, 8.07706784555988, 4.82859189180109, 4.28049047919568, 4.02054752142086, 4.45446182299703, 2.88902557744596, 4.17698124193575, 6.31474248231764, 2.68657606391183, 3.75708892669439, 4.70294050809375, 6.35750639997654, 5.66591712203293, 5.1676226656419, 6.36111068522507, 5.0746871785069, 3.74549388607439, 10.0499160660981, 2.73392821921647, 7.5468698295455, 3.63310870671515, 4.73756281172226, 3.12831980852897, 5.92478381773712, 3.97278768529811, 4.43603447353224, 3.22165005512334, 2.64048226457915, 4.82170867550029, 3.88802663642624, 6.28071352879497, 7.1898792291212, 3.45069580057411, 2.11874855961612, 6.83308998981622, 4.88594913751698, 7.2043715042717, 5.92944522632847, 5.28125713924232, 2.92406012836832, 5.51193983406794, 3.92034936881849, 4.02863562948636, 2.63086007943162, 2.29816871384959, 5.43277606496536, 2.748057506715, 2.98832890910102, 3.86750736412989, 10.0251585616053, 2.4508507570229, 5.15539283003769, 4.92251312085952, 3.7560826804466, 3.55555381750724, 3.80501827417895, 6.9500408077286, 5.63753820219307, 4.34417512875296, 2.38134080759689, 6.02021367624557, 7.61923679606813, 4.2639565075926, 5.19690782449524, 2.77914619706371, 2.80469912067042, 2.5030368187632, 3.66180330645551, 4.73586073723542, 4.03431276216711, 2.65910091882713, 2.83278553692168, 7.41646908081112, 1.87620181096256, 1.51781201506458, 1.92751580314289, 2.43506169436137, 1.88641686599088, 4.49013870147502, 2.15361460668737, 3.46482799242971, 2.69942251292495, 5.49300237653247, 3.34643344573202, 4.094064955793, 8.96571331963092, 2.22907411871184, 4.38143383339268, 6.52622723104758, 3.96979373172918, 5.52311167411852, 7.12115478587954), .Dim = c(124L, 2L), .Dimnames = list(c("1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2"), NULL)) I made a dot plot between them. what i want to do is to bold the size of dots,compared to that of others, for the following ranges -------80<x<100 and 2<y<4 -------40<x<60 and 8<y<10 -------100<x<120 and 6<y<8 Then, i also want to draw square around those dots falling in these ranges and finally naming the areas with alphabets A, B and C. Is there a way of doing it? Thanks in advance Eliza [[alternative HTML version deleted]]
Follow the posting guide! Code code code. (What you call a "dotplot" I think is what most of us call a scatterplot. And there are many ways of doing this in R and packages, and we have no idea what you used.) Cheers, Bert On Sat, Oct 19, 2013 at 2:29 PM, eliza botto <eliza_botto at hotmail.com> wrote:> Dear useRs, > > I have the following data "z" of two variables "x"(z[,1]) and "y"(z[,2]). > >> dput(z) > > structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 4.36222673881464, 3.69969030080286, 4.2171385106796, 3.13216766340978, 4.48272959444564, 5.15902588302327, 5.48017158746089, 4.27937198622481, 6.87798628712867, 10.6244257045475, 4.28697206373731, 2.36185506591713, 3.8999910824793, 3.53659639173799, 3.55002661079475, 1.69933515030185, 3.05902585757021, 7.36381894775327, 7.40245656365444, 3.6848569064997, 6.08996204878611, 6.28326065486612, 3.94011667392145, 4.32959623927668, 4.53659549630782, 10.5471767576564, ! > 3.25988629354992, 4.09457312472741, 3.80883550148271, 3.31050022622877, 4.97298874506525, 4.44111508385058, 8.07706784555988, 4.82859189180109, 4.28049047919568, 4.02054752142086, 4.45446182299703, 2.88902557744596, 4.17698124193575, 6.31474248231764, 2.68657606391183, 3.75708892669439, 4.70294050809375, 6.35750639997654, 5.66591712203293, 5.1676226656419, 6.36111068522507, 5.0746871785069, 3.74549388607439, 10.0499160660981, 2.73392821921647, 7.5468698295455, 3.63310870671515, 4.73756281172226, 3.12831980852897, 5.92478381773712, 3.97278768529811, 4.43603447353224, 3.22165005512334, 2.64048226457915, 4.82170867550029, 3.88802663642624, 6.28071352879497, 7.1898792291212, 3.45069580057411, 2.11874855961612, 6.83308998981622, 4.88594913751698, 7.2043715042717, 5.92944522632847, 5.28125713924232, 2.92406012836832, 5.51193983406794, 3.92034936881849, 4.02863562948636, 2.63086007943162, 2.29816871384959, 5.43277606496536, 2.748057506715, 2.98832890910102, 3.86750736412989, 10.02! > 51585616053, 2.4508507570229, 5.15539283003769, 4.92251312085952, 3.75 > 60826804466, 3.55555381750724, 3.80501827417895, 6.9500408077286, 5.63753820219307, 4.34417512875296, 2.38134080759689, 6.02021367624557, 7.61923679606813, 4.2639565075926, 5.19690782449524, 2.77914619706371, 2.80469912067042, 2.5030368187632, 3.66180330645551, 4.73586073723542, 4.03431276216711, 2.65910091882713, 2.83278553692168, 7.41646908081112, 1.87620181096256, 1.51781201506458, 1.92751580314289, 2.43506169436137, 1.88641686599088, 4.49013870147502, 2.15361460668737, 3.46482799242971, 2.69942251292495, 5.49300237653247, 3.34643344573202, 4.094064955793, 8.96571331963092, 2.22907411871184, 4.38143383339268, 6.52622723104758, 3.96979373172918, 5.52311167411852, 7.12115478587954), .Dim = c(124L, 2L), .Dimnames = list(c("1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2"! > , "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2"), NULL)) > > I made a dot plot between them. what i want to do is to bold the size of dots,compared to that of others, for the following ranges > -------80<x<100 and 2<y<4 > > -------40<x<60 and 8<y<10 > > -------100<x<120 and 6<y<8 > > Then, i also want to draw square around those dots falling in these ranges and finally naming the areas with alphabets A, B and C. > > Is there a way of doing it? > > Thanks in advance > > Eliza > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374
On 10/20/2013 08:29 AM, eliza botto wrote:> Dear useRs, > ... > > I made a dot plot between them. what i want to do is to bold the size of dots,compared to that of others, for the following ranges > -------80<x<100 and 2<y<4 > > -------40<x<60 and 8<y<10 > > -------100<x<120 and 6<y<8 > > Then, i also want to draw square around those dots falling in these ranges and finally naming the areas with alphabets A, B and C. > > Is there a way of doing it? >Hi Eliza, Your data was a bit corrupted, but try this: z1<-cbind(z,rep(1,124)) z1[z1[,1]>80 & z1[,1]<100 & z1[,2]>2 & z1[,2]<4,3]<-2 z1[z1[,1]>40 & z1[,1]<60 & z1[,2]>8 & z1[,2]<10,3]<-2 z1[z1[,1]>100 & z1[,1]<120 & z1[,2]>6 & z1[,2]<8,3]<-2 plot(z1[,1],z1[,2],cex=z1[,3]) rect(80,2,100,4) rect(40,8,60,10) rect(100,6,120,8) text(c(90,50,110),c(3,9,7),LETTERS[1:3]) Jim
Hi, May be this also helps.? Using ?ggplot() indx <- 1 + 2*((z[,1]>80 & z[,1] < 100) & (z[,2]>2 & z[,2] < 4)) + 4*((z[,1]>40 & z[,1] < 60) & (z[,2]>8 & z[,2] < 10)) + 8*((z[,1]>100 & z[,1] < 120) & (z[,2]> 6 & z[,2] < 8)) ?indx[indx>1] <- 2 z1<-cbind(z,indx) z2 <- as.data.frame(z1) colnames(z2)[1:2] <- c("x","y") rect1 <- data.frame(xmin=c(80,40,100),xmax=c(100,60,120),ymin=c(2,8,6),ymax=c(4,10,8)) library(ggplot2) p <- ggplot(x=x, y=y,data=z2)+scale_size(range=c(2,4))+ ?geom_rect(data=rect1, aes(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax),fill='gray80', alpha=0.8) + geom_point(data=z2,aes(x=x,y=y,size=indx,colour=factor(indx)))+scale_colour_manual(values=c("black","red"))+theme_bw() +theme(legend.position = "none") p+ annotate("text", label = "A", x = 90, y = 3) + ?annotate("text", label = "B", x = 50, y = 9) + ?annotate("text", label = "C", x = 110, y = 7) #or p+ geom_text(aes(90, 3, label="A")) + geom_text(aes(50, 9, label="B")) + ?geom_text(aes(110, 7, label="C")) A.K. On Saturday, October 19, 2013 5:30 PM, eliza botto <eliza_botto at hotmail.com> wrote: Dear useRs, I have the following data "z" of two variables "x"(z[,1]) and "y"(z[,2]).> dput(z)structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 4.36222673881464, 3.69969030080286, 4.2171385106796, 3.13216766340978, 4.48272959444564, 5.15902588302327, 5.48017158746089, 4.27937198622481, 6.87798628712867, 10.6244257045475, 4.28697206373731, 2.36185506591713, 3.8999910824793, 3.53659639173799, 3.55002661079475, 1.69933515030185, 3.05902585757021, 7.36381894775327, 7.40245656365444, 3.6848569064997, 6.08996204878611, 6.28326065486612, 3.94011667392145, 4.32959623927668, 4.53659549630782, 10.5471767576564, ! 3.25988629354992, 4.09457312472741, 3.80883550148271, 3.31050022622877, 4.97298874506525, 4.44111508385058, 8.07706784555988, 4.82859189180109, 4.28049047919568, 4.02054752142086, 4.45446182299703, 2.88902557744596, 4.17698124193575, 6.31474248231764, 2.68657606391183, 3.75708892669439, 4.70294050809375, 6.35750639997654, 5.66591712203293, 5.1676226656419, 6.36111068522507, 5.0746871785069, 3.74549388607439, 10.0499160660981, 2.73392821921647, 7.5468698295455, 3.63310870671515, 4.73756281172226, 3.12831980852897, 5.92478381773712, 3.97278768529811, 4.43603447353224, 3.22165005512334, 2.64048226457915, 4.82170867550029, 3.88802663642624, 6.28071352879497, 7.1898792291212, 3.45069580057411, 2.11874855961612, 6.83308998981622, 4.88594913751698, 7.2043715042717, 5.92944522632847, 5.28125713924232, 2.92406012836832, 5.51193983406794, 3.92034936881849, 4.02863562948636, 2.63086007943162, 2.29816871384959, 5.43277606496536, 2.748057506715, 2.98832890910102, 3.86750736412989, 10.02! 51585616053, 2.4508507570229, 5.15539283003769, 4.92251312085952, 3.75 60826804466, 3.55555381750724, 3.80501827417895, 6.9500408077286, 5.63753820219307, 4.34417512875296, 2.38134080759689, 6.02021367624557, 7.61923679606813, 4.2639565075926, 5.19690782449524, 2.77914619706371, 2.80469912067042, 2.5030368187632, 3.66180330645551, 4.73586073723542, 4.03431276216711, 2.65910091882713, 2.83278553692168, 7.41646908081112, 1.87620181096256, 1.51781201506458, 1.92751580314289, 2.43506169436137, 1.88641686599088, 4.49013870147502, 2.15361460668737, 3.46482799242971, 2.69942251292495, 5.49300237653247, 3.34643344573202, 4.094064955793, 8.96571331963092, 2.22907411871184, 4.38143383339268, 6.52622723104758, 3.96979373172918, 5.52311167411852, 7.12115478587954), .Dim = c(124L, 2L), .Dimnames = list(c("1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2"! , "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2", "1_2"), NULL)) I made a dot plot between them. what i want to do is to bold the size of dots,compared to that of others, for the following ranges -------80<x<100 and 2<y<4 -------40<x<60 and 8<y<10 -------100<x<120 and 6<y<8 Then, i also want to draw square around those dots falling in these ranges and finally naming the areas with alphabets A, B and C. Is there a way of doing it? Thanks in advance Eliza ??? ??? ??? ? ??? ??? ? ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.