[R] Multiple xyplots
Hi everyone, I'm hoping you can give me some pointers. I have a requirement to draw multiple (103) xy line plots onto one output device. Ideally the plots should be displayed in a hexagonal grid (example at www.maladmin.com/example.jpg). I can calculate the locations for each waveform but am wondering how to create multiple plotting areas. I have come accross references to a package grid (which doesn't seem to be in my CRAN mirror probability.ca) and lattice but I'm not sure if I'm on the correct lines. Any advice gratefully received. Thanks Tom -- --Tom Wright | Contact me: | | Skype: 0121 288 0756tomwright01) | | MSN: [EMAIL PROTECTED]| | Jabber: [EMAIL PROTECTED] | | ICQ: 423913453| |___| Ever since prehistoric times, wise men have tried to understand what, exactly, make people laugh. That's why they were called "wise men." All the other prehistoric people were out puncturing each other with spears, and the wise men were back in the cave saying: "How about: Would you please take my wife? No. How about: Here is my wife, please take her right now. No How about: Would you like to take something? My wife is available. No. How about ..." -- Dave Barry, "Why Humor is Funny" __ R-help@stat.math.ethz.ch 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.
Re: [R] Multiple xyplots
On 9/5/07, Tom Wright <[EMAIL PROTECTED]> wrote: > Hi everyone, > I'm hoping you can give me some pointers. I have a requirement to draw > multiple (103) xy line plots onto one output device. Ideally the plots > should be displayed in a hexagonal grid (example at > www.maladmin.com/example.jpg). I can calculate the locations for each > waveform but am wondering how to create multiple plotting areas. I have > come accross references to a package grid (which doesn't seem to be in > my CRAN mirror probability.ca) and lattice but I'm not sure if I'm on > the correct lines. > Any advice gratefully received. grid seems like the right choice to me (it comes bundled with R, so it's not available as a separate package). Here's an example that may give you a few hints: library(grid) grid.newpage() for (i in 1:30) grid.lines(x = 0:20/21, y = sin(70 * runif(1) * 0:20/21), vp = viewport(x = runif(1), y = runif(1), height = 0.05, width = 0.05)) See the package documentation, or Paul Murrell's book "R Graphics" for more. -Deepayan __ R-help@stat.math.ethz.ch 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.
Re: [R] Multiple xyplots
Take a look at the my.symbols function in the TeachingDemos package. The last example shows how to create a hexagonal grid and the 2nd to last example shows how to plot several small line plots onto a larger plot. Combining these 2 examples should give you what you want. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Tom Wright > Sent: Wednesday, September 05, 2007 8:54 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Multiple xyplots > > Hi everyone, > I'm hoping you can give me some pointers. I have a > requirement to draw multiple (103) xy line plots onto one > output device. Ideally the plots should be displayed in a > hexagonal grid (example at www.maladmin.com/example.jpg). I > can calculate the locations for each waveform but am > wondering how to create multiple plotting areas. I have come > accross references to a package grid (which doesn't seem to > be in my CRAN mirror probability.ca) and lattice but I'm not > sure if I'm on the correct lines. > Any advice gratefully received. > Thanks > Tom > > -- > --Tom Wright > > | Contact me: | > | Skype: 0121 288 0756tomwright01) | > | MSN: [EMAIL PROTECTED]| > | Jabber: [EMAIL PROTECTED] | > | ICQ: 423913453| > |___| > > > Ever since prehistoric times, wise men have tried to > understand what, exactly, make people laugh. That's why they > were called "wise men." > All the other prehistoric people were out puncturing each > other with spears, and the wise men were back in the cave > saying: "How about: > Would you please take my wife? No. How about: Here is my > wife, please take her right now. No How about: Would you > like to take something? > My wife is available. No. How about ..." > -- Dave Barry, "Why Humor is Funny" > > __ > R-help@stat.math.ethz.ch 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. > __ R-help@stat.math.ethz.ch 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.
[R] multiple xyplots on the same graph
I am new to R and am having trouble plotting multiple xyplots on the same graph. I have a dataframe x1 with 3 columns month, var1, var2. Month is a factor while var1 and var2 are numeric. Reading through the archives I learned to plot var1 vs month and var2 vs month and have them as two plots in one window by doing the following library(lattice) x<-xyplot(var1~month,type="b") y<-xyplot(var2~month,type="b") print(x,split(c(1,1,1,2),more=TRUE) print(y,split(c(1,2,1,2)) How do I get just one plot with month as the x axis and two lines for var1 and var2 ? thanks swami __ R-help@stat.math.ethz.ch 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.
[R] Multiple xyplots on the same page
Hi, I am using the "xyplot" function in the "lattice" package to generate multiple plots, but I would like to have them plotted on the same page. I would like to set something equivalent to the command: par(mfrow=c(2,2)), in order that I can plot 4 xyplots on the same page. How can I do this in "xyplot"? I am using R version 2.1.1 on Windows. Thanks very much, Ravi. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple xyplots on the same graph
On 9/28/06, S. Swaminathan <[EMAIL PROTECTED]> wrote: > I am new to R and am having trouble plotting multiple xyplots on the same > graph. > I have a dataframe x1 with 3 columns month, var1, var2. Month is a factor > while var1 and var2 are numeric. > Reading through the archives I learned to plot var1 vs month and var2 vs > month and have them as two plots in one window by doing the following > library(lattice) > x<-xyplot(var1~month,type="b") > y<-xyplot(var2~month,type="b") > print(x,split(c(1,1,1,2),more=TRUE) > print(y,split(c(1,2,1,2)) > > How do I get just one plot with month as the x axis and two lines for var1 > and var2 ? xyplot(var1 + var2 ~ month, data = x1, type = "b") Incidentally, R has a help system, and you will usually get more reliable information if you read the help page of the function you are using rather than "read through the archives". In this case, that would be done by typing ?xyplot or help(xyplot). -Deepayan __ R-help@stat.math.ethz.ch 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.
Re: [R] Multiple xyplots on the same page
See ?print.trellis. Andy From: Ravi Varadhan > > Hi, > > > > I am using the "xyplot" function in the "lattice" package to generate > multiple plots, but I would like to have them plotted on the > same page. I > would like to set something equivalent to the command: > par(mfrow=c(2,2)), > in order that I can plot 4 xyplots on the same page. How can > I do this in > "xyplot"? > > I am using R version 2.1.1 on Windows. > > > > Thanks very much, > > Ravi. > > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Multiple xyplots on the same page
Thank you very much, Andy. It was quite helpful, and I was able to plot 4 xyplots on one page, but I still couldn't get the legends to fit properly within each plot, as they were not scaled down automatically. Any hints on how I can shrink the size of legend in each plot to fit? Thanks, Ravi. > -Original Message- > From: Liaw, Andy [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 31, 2006 1:04 PM > To: 'Ravi Varadhan'; r-help@stat.math.ethz.ch > Subject: RE: [R] Multiple xyplots on the same page > > See ?print.trellis. > > Andy > > From: Ravi Varadhan > > > > Hi, > > > > > > > > I am using the "xyplot" function in the "lattice" package to generate > > multiple plots, but I would like to have them plotted on the > > same page. I > > would like to set something equivalent to the command: > > par(mfrow=c(2,2)), > > in order that I can plot 4 xyplots on the same page. How can > > I do this in > > "xyplot"? > > > > I am using R version 2.1.1 on Windows. > > > > > > > > Thanks very much, > > > > Ravi. > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > > > > -- > > Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Multiple xyplots on the same page
Sorry, that's beyond me. I've never tried that myself. Andy From: Ravi Varadhan > > Thank you very much, Andy. It was quite helpful, and I was > able to plot 4 > xyplots on one page, but I still couldn't get the legends to > fit properly > within each plot, as they were not scaled down automatically. > Any hints on > how I can shrink the size of legend in each plot to fit? > > Thanks, > Ravi. > > > > -Original Message- > > From: Liaw, Andy [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, January 31, 2006 1:04 PM > > To: 'Ravi Varadhan'; r-help@stat.math.ethz.ch > > Subject: RE: [R] Multiple xyplots on the same page > > > > See ?print.trellis. > > > > Andy > > > > From: Ravi Varadhan > > > > > > Hi, > > > > > > > > > > > > I am using the "xyplot" function in the "lattice" package > to generate > > > multiple plots, but I would like to have them plotted on the > > > same page. I > > > would like to set something equivalent to the command: > > > par(mfrow=c(2,2)), > > > in order that I can plot 4 xyplots on the same page. How can > > > I do this in > > > "xyplot"? > > > > > > I am using R version 2.1.1 on Windows. > > > > > > > > > > > > Thanks very much, > > > > > > Ravi. > > > > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! > > > http://www.R-project.org/posting-guide.html > > > > > > > > > > > > > -- > > > > > Notice: This e-mail message, together with any > attachments, contains > > information of Merck & Co., Inc. (One Merck Drive, > Whitehouse Station, New > > Jersey, USA 08889), and/or its affiliates (which may be > known outside the > > United States as Merck Frosst, Merck Sharp & Dohme or MSD > and in Japan, as > > Banyu) that may be confidential, proprietary copyrighted > and/or legally > > privileged. It is intended solely for the use of the > individual or entity > > named on this message. If you are not the intended > recipient, and have > > received this message in error, please notify us > immediately by reply e- > > mail and then delete it from your system. > > > -- > > > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Multiple xyplots on the same page
On 2/1/06, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > Thank you very much, Andy. It was quite helpful, and I was able to plot 4 > xyplots on one page, but I still couldn't get the legends to fit properly > within each plot, as they were not scaled down automatically. Any hints on > how I can shrink the size of legend in each plot to fit? The parameter to `shrink' things is usually called 'cex' (or some variation of that). There is (or at least should be) a way to control the size of each component of a key (described in the documentation). There's no global way to shrink or expand a key. Deepayan -- http://www.stat.wisc.edu/~deepayan/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Multiple xyplots on the same page
Hi, Ravi, How are you creating the legend? Here's a trivial example where you can add a cex argument to "auto.key": library(lattice) trellis.par.set(theme = col.whitebg()) xy <- xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos, type = "a", auto.key = list(x = 0.2, y = 0.9, cex = 0.75, points = FALSE, lines = TRUE)) print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE) print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE) print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE) print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE) HTH, --sundar Liaw, Andy wrote: > Sorry, that's beyond me. I've never tried that myself. > > Andy > > From: Ravi Varadhan > >>Thank you very much, Andy. It was quite helpful, and I was >>able to plot 4 >>xyplots on one page, but I still couldn't get the legends to >>fit properly >>within each plot, as they were not scaled down automatically. >>Any hints on >>how I can shrink the size of legend in each plot to fit? >> >>Thanks, >>Ravi. >> >> >> >>>-Original Message- >>>From: Liaw, Andy [mailto:[EMAIL PROTECTED] >>>Sent: Tuesday, January 31, 2006 1:04 PM >>>To: 'Ravi Varadhan'; r-help@stat.math.ethz.ch >>>Subject: RE: [R] Multiple xyplots on the same page >>> >>>See ?print.trellis. >>> >>>Andy >>> >>>From: Ravi Varadhan >>> >>>>Hi, >>>> >>>> >>>> >>>>I am using the "xyplot" function in the "lattice" package >> >>to generate >> >>>>multiple plots, but I would like to have them plotted on the >>>>same page. I >>>>would like to set something equivalent to the command: >>>>par(mfrow=c(2,2)), >>>>in order that I can plot 4 xyplots on the same page. How can >>>>I do this in >>>>"xyplot"? >>>> >>>>I am using R version 2.1.1 on Windows. >>>> >>>> >>>> >>>>Thanks very much, >>>> >>>>Ravi. >>>> >>>> >>>>[[alternative HTML version deleted]] >>>> >>>>__ >>>>R-help@stat.math.ethz.ch mailing list >>>>https://stat.ethz.ch/mailman/listinfo/r-help >>>>PLEASE do read the posting guide! >>>>http://www.R-project.org/posting-guide.html >>>> >>>> >>> >>> >>> >>-- >> >> >>> >>>Notice: This e-mail message, together with any >> >>attachments, contains >> >>>information of Merck & Co., Inc. (One Merck Drive, >> >>Whitehouse Station, New >> >>>Jersey, USA 08889), and/or its affiliates (which may be >> >>known outside the >> >>>United States as Merck Frosst, Merck Sharp & Dohme or MSD >> >>and in Japan, as >> >>>Banyu) that may be confidential, proprietary copyrighted >> >>and/or legally >> >>>privileged. It is intended solely for the use of the >> >>individual or entity >> >>>named on this message. If you are not the intended >> >>recipient, and have >> >>>received this message in error, please notify us >> >>immediately by reply e- >> >>>mail and then delete it from your system. >>> >> >>-- >> >> >>> >> >> > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html