Ignacio Alborés
2010-Nov-23 18:48 UTC
[R] Barplot and plot means with confidence intervals in the same plot
I want to obtain a barplot with error bars and a mean plot with error bars with other scale on the left in the same plot. I need help to get the same x axis (centered) when overlay two plots (barplot2 and plotCI (or lineplot.CI) with errorbars), with diferent y axis. I use par (new=T) but the X axis names are not centered with the figures. An example of my data: mean1<-cbind(55.5,56.42,56.38,55.28) SD1<-cbind(10,9 ,7 ,3) x<-rbind(mean1,SD1) colnames(x)<-c("Autumn","Spring","Summer","Winter") rownames(x)<-c("MeanProts","SD") mean2<-cbind(10,15,9,8) SD2<-cbind(2,3 ,1 ,5) y<-rbind(mean2,SD2) colnames(y)<-c("Autumn","Spring","Summer","Winter") rownames(y)<-c("MeanDNA","SD") Thanks in advance. Nacho -- Ignacio Alborés Blanes Grupo de Investigación en Recursos Marinos y Pesquerías Universidade de A Coruña. Campus da Zapateira. C/Rúa da Fraga, 10. 15008. A Coruña. Spain. +34(981)167000 ext. 2204 Fax. +34(981)167065 www.recursosmarinos.net [[alternative HTML version deleted]]
Yuliya Matveyeva
2010-Nov-23 20:21 UTC
[R] Barplot and plot means with confidence intervals in the same plot
2010/11/23 Ignacio Alborés <nachoalbores@gmail.com>> I want to obtain a barplot with error bars and a mean plot with error bars > with other scale on the left in the same plot. I need help to get the > same > x axis (centered) when overlay two plots (barplot2 and plotCI (or > lineplot.CI) with errorbars), with diferent y axis. I use par (new=T) but > the X axis names are not centered with the figures. > > An example of my data: > > > mean1<-cbind(55.5,56.42,56.38,55.28) > SD1<-cbind(10,9 ,7 ,3) > x<-rbind(mean1,SD1) > colnames(x)<-c("Autumn","Spring","Summer","Winter") > rownames(x)<-c("MeanProts","SD") > > > mean2<-cbind(10,15,9,8) > SD2<-cbind(2,3 ,1 ,5) > y<-rbind(mean2,SD2) > colnames(y)<-c("Autumn","Spring","Summer","Winter") > rownames(y)<-c("MeanDNA","SD") > > Thanks in advance. > > > Nacho > > > > > You would probably want to use the `xlim` and `ylim` parameters in your > call to plot (set the x and y axis explicitly). >Plus if you want two different y-axes on one plot, use axes = FALSE in your call to plot, and then use the> `axis` function to add the axis. >?axis Yuliya.> -- > Ignacio Alborés Blanes > Grupo de Investigación en Recursos Marinos y Pesquerías > Universidade de A Coruña. > Campus da Zapateira. C/Rúa da Fraga, 10. > 15008. A Coruña. Spain. > +34(981)167000 ext. 2204 Fax. +34(981)167065 > www.recursosmarinos.net > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@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. > >[[alternative HTML version deleted]]