[R] Three plots with logged X-axis in the same plot

Duncan Mackay mackay at northnet.com.au
Fri May 17 03:47:03 CEST 2013


Hi Patrik,

Using plot you could give the panel extra height 
by changing the cex of the labels etc and mai of the top expecially.
Otherwise you could use xyplot and split the data 
into 3 - lattice with panels can be space saving

dat <- data.frame(max = hr_max, min=hr_min, med = med_names)
dat$gp <- c(rep(1:3, each = 17),3)
dat$N <- c(1:17,1:17,1:18)

xyplot(N ~ max |gp, data = dat,
        xlim = c(-10,160),
        layout = c(3,1),
        strip = F,
        subscripts = T,
        panel = function(x,y,subscripts,...){
          panel.grid(...)
          panel.arrows(dat[subscripts,"min"],y,dat[subscripts,"max"],y, 
cod = 3, angle=90,length=0.05)

          ltext((dat[subscripts,"min"]+dat[subscripts,"max"])/2,y+0.5,dat[subscripts,"med"], 
cex = 0.6)
       }
)

some tweaking needs to be done to suit

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au


At 10:57 17/05/2013, you wrote:
>On 05/16/2013 11:07 PM, Öhagen Patrik wrote:
>>Hi Jim,Thank you for your input! I am working 
>>with the text and arrow command in each of the 
>>graphs. I think it would be far to messy to 
>>plot them all in one graph (50+ point estimates and confidence intervals).
>>
>>par(mfrow=c(1,3)) is a step in the proper 
>>direction but I fail to see how I can reduce 
>>the amount of unused printing area around the three graphs.
>>
>Hi Patrik,
>Perhaps you could simply change the aspect ratio of the plot. Try this:
>
>med_names<-c("Alcohol Amnestic Disorder",
>"Alcoholic Cirrhosis",
>"Korsakoff Syndrome",
>"Alcoholic Seizure",
>"Alcoholic Polyneuropathy",
>"Adrenoleukodystrophy",
>"Alexander Disease",
>"Alexia",
>"Allergic Angiitis",
>"Allergy, Food",
>"Alphanodavirus",
>"alpha-Thalassemia",
>"Alphavirus Infection",
>"Alstrom Syndrome",
>"Altitude Sickness",
>"Alzheimer Dementia",
>"Bladder Stones",
>"Blastomycosis",
>"Nasal Bleeding",
>"Blepharospasm",
>"River Blindness",
>"Blisters",
>"Sinoatrial block",
>"Bundle Branch blocks",
>"Blood Borne Pathogens",
>"Blood Coagulation Disorder",
>"Blood Group Incompatibility",
>"Surgical Blood Loss",
>"Blood Poisoning",
>"Hypertentsion",
>"Bluecomb Virus",
>"Blue-Eared Pig Disease",
>"Blunt Injury",
>"Chalones",
>"Charcot Marie Tooth Disease",
>"Chest Pain",
>"Chiari's Syndrome",
>"Chigoe Flea",
>"Childbirth, Home",
>"Chlamydia Infection",
>"Choanal Atresia",
>"Cholecystolithiasis",
>"Cholera Morbus",
>"Chondromalacia Patellae",
>"Choreic Movement",
>"Chorioretinitis",
>"Christmas Disease",
>"Chromosomal Inversion",
>"Chromosome Disorder",
>"Chronic Fatigue Disorder",
>"Chronic Wasting Disease",
>"Churg-Strauss Syndrome")
>hr_min<-sample(45:80,52,TRUE)
>hr_max<-hr_min+sample(10:40,52,TRUE)
>x11(height=10)
>plot(50,xlim=range(c(hr_min,hr_max)),ylim=c(0,53),type="n")
>arrows(x0=hr_min,y0=0.5:51.5,x1=hr_max,code=3,length=0.03,angle=90)
>text((hr_min+hr_max)/2,1:52,med_names,cex=0.6)
>
>Jim
>
>______________________________________________
>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.
>



More information about the R-help mailing list