I have, say, three plots with several medical terms on the y-axis plotted against HR's on a log-scaled x-axis. In order to highlight the time profile for the different plots, I would like to "merge" (put them next to each other, if that makes sense) together the log scaled x-axises and present the data in a single plot. How to do it? Using par(mfrow=c(1,3)) seems to waste too much printing area. Any suggestions? Thank you in advance! Cheers, Patrik [[alternative HTML version deleted]]
On 05/16/2013 09:50 PM, ?hagen Patrik wrote:> I have, say, three plots with several medical terms on the y-axis plotted against HR's on a log-scaled x-axis. In order to highlight the time profile for the different plots, I would like to "merge" (put them next to each other, if that makes sense) together the log scaled x-axises and present the data in a single plot. > > How to do it? Using par(mfrow=c(1,3)) seems to waste too much printing area. > > Any suggestions? >Hi Patrik, This appears more like a diagram with the x dimension of log heart rate and various terms appearing the the plot space that are particular to a value or range of that heart rate. I would first think of using the "text" function to place the medical terms, perhaps with the "arrow" function showing a range. It may be simpler to use the "boxed.labels" function in the plotrix package to overlay the ranges. Jim
Can you supply us with a bit of sample data? It's not clear from your description of the problem if you are working with equivalent x -scales where it would be very easy to just plot all curves on one plot or if there are scale or item differences that might require diffferent panels. https://github.com/hadley/devtools/wiki/Reproducibility John Kane Kingston ON Canada> -----Original Message----- > From: patrik.ohagen at mpa.se > Sent: Thu, 16 May 2013 11:50:20 +0000 > To: r-help at r-project.org > Subject: [R] Three plots with logged X-axis in the same plot > > I have, say, three plots with several medical terms on the y-axis plotted > against HR's on a log-scaled x-axis. In order to highlight the time > profile for the different plots, I would like to "merge" (put them next > to each other, if that makes sense) together the log scaled x-axises and > present the data in a single plot. > > How to do it? Using par(mfrow=c(1,3)) seems to waste too much printing > area. > > Any suggestions? > > Thank you in advance! > > Cheers, Patrik > > > [[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.____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
On 16/05/2013 7:50 AM, ?hagen Patrik wrote:> I have, say, three plots with several medical terms on the y-axis plotted against HR's on a log-scaled x-axis. In order to highlight the time profile for the different plots, I would like to "merge" (put them next to each other, if that makes sense) together the log scaled x-axises and present the data in a single plot. > > How to do it? Using par(mfrow=c(1,3)) seems to waste too much printing area.You can change the margins using par(mar=). If you want things closer together, shrink them. You might also want to leave off the boxes around the plots; use bty="n" for that. For example, x <- rnorm(100) oldmargins <- par("mar") mar <- oldmargins mar[c(2,4)] <- c(2.1, 0.1) # shrink the sides par(mar=mar, mfrow=c(1,3)) plot(x, bty="n") plot(x, bty="n") plot(x, bty="n") Duncan Murdoch> > Any suggestions? > > Thank you in advance! > > Cheers, Patrik > > > [[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.
Okay so you do want independent panels. When I asked for sample data it does not have to be anything real. All we need is something that has a similar data structure. We can do the same type of graph with earhquake data, medical data or voter response. Just substite random names for the med terms and use a random number generator for the meaurements. This , length of vectors in different matrices or dataframes, etc are the crucial bits of information. The actual data is really immaterial. For example here are two different data structures with the "almost the same data but in different formats and with an important difference between dat1$aa and dat2$aa. dat1 <- structure(list(aa = structure(1:5, .Label = c("a", "b", "c", "d", "e"), class = "factor"), bb = c(-0.00582694254724667, -0.716808619114487, 0.0333078304958157, 0.382137504304074, -1.07626847615088)), .Names = c("aa", "bb"), row.names = c(NA, -5L), class = "data.frame") dat2 <- structure(list(aa = c("a", "b", "c", "d", "e"), bb = c(0.149330272058851, 0.4024610008935, -1.10212110787262, -0.603049153794929, 0.894804687148742 )), .Names = c("aa", "bb")) str(dat1) str(dat2) John Kane Kingston ON Canada> -----Original Message----- > From: patrik.ohagen at mpa.se > Sent: Thu, 16 May 2013 13:09:26 +0000 > To: jrkrideau at inbox.com, r-help at r-project.org > Subject: SV: [R] Three plots with logged X-axis in the same plot > > > > Hi John, Thank you for your input! The thing is that the graph would be > to messy if I plotted all the data in a single plot. I wish I could share > some data but I am all of the stuff is highly confidential. Sorry. > > > Cheers, Patrik > > -----Ursprungligt meddelande----- > Fr?n: John Kane [mailto:jrkrideau at inbox.com] > Skickat: den 16 maj 2013 14:53 > Till: ?hagen Patrik; r-help at r-project.org > ?mne: RE: [R] Three plots with logged X-axis in the same plot > > Can you supply us with a bit of sample data? It's not clear from your > description of the problem if you are working with equivalent x -scales > where it would be very easy to just plot all curves on one plot or if > there are scale or item differences that might require diffferent panels. > > https://github.com/hadley/devtools/wiki/Reproducibility > > John Kane > Kingston ON Canada > > >> -----Original Message----- >> From: patrik.ohagen at mpa.se >> Sent: Thu, 16 May 2013 11:50:20 +0000 >> To: r-help at r-project.org >> Subject: [R] Three plots with logged X-axis in the same plot >> >> I have, say, three plots with several medical terms on the y-axis >> plotted >> against HR's on a log-scaled x-axis. In order to highlight the time >> profile for the different plots, I would like to "merge" (put them next >> to each other, if that makes sense) together the log scaled x-axises and >> present the data in a single plot. >> >> How to do it? Using par(mfrow=c(1,3)) seems to waste too much printing >> area. >> >> Any suggestions? >> >> Thank you in advance! >> >> Cheers, Patrik >> >> >> [[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. > > ____________________________________________________________ > FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! > Check it out at http://www.inbox.com/earth____________________________________________________________ GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails