James Maas (MED)
2012-Oct-03 13:41 UTC
[R] error bars on line plot with error bars using ggplot
I'm new to this and struggling away with ggplot. I need to plot some line graphs for about 4 series. I have the values to plot and also the value of the standard error of the value. Is it possible to plot the standard error bars when the value are already calculated as opposed to letting R do the analysis to calculate the SE bars? Any simple example would be most appreciated. Thanks J --------------------- Dr. Jim Maas University of East Anglia [[alternative HTML version deleted]]
David Winsemius
2012-Oct-03 15:30 UTC
[R] error bars on line plot with error bars using ggplot
On Oct 3, 2012, at 6:41 AM, James Maas (MED) wrote:> I'm new to this and struggling away with ggplot. I need to plot some line graphs for about 4 series. I have the values to plot and also the value of the standard error of the value. Is it possible to plot the standard error bars when the value are already calculated as opposed to letting R do the analysis to calculate the SE bars?The usual way to do that in base graphics is with the arrows function using an angle of 90.> > Any simple example would be most appreciated.Hey, that's _our_ line. Solutions extended when reproducible example provided. See the standard footer. -- David Winsemius, MD Alameda, CA, USA
> I'm new to this and struggling away with ggplot. I need to > plot some line graphs for about 4 series. I have the values > to plot and also the value of the standard error of the > value. Is it possible to plot the standard error bars when > the value are already calculated as opposed to letting R do > the analysis to calculate the SE bars? >Try googling 'error bars in ggplot' I found a useful description at http://wiki.stdout.org/rcookbook/Graphs/Plotting%20means%20and%20error%20bars%20%28ggplot2%29/ ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}
Yakamu Yakamu
2012-Oct-03 17:50 UTC
[R] how can I adjust the ranges of my y-axis in barplot?
Hi all, I am making 2 barplots with 3 different bars inside with command : bar.wdHo<-barplot(wdHo.mean, names=c(""), cex.lab=1.0, cex.axis=1, cex.names=1, ylim=c(0,15), xlab="", ylab=expression(paste("Thickness (mm"^{2},")")), density=c(0,27,200), col=c("grey90","black","grey"), beside=TRUE, axis.lty=1) and the other one : bar.wdHo<-barplot(wdHo.mean, names=c(""), cex.lab=1.0, cex.axis=1, cex.names=1, ylim=c(0,5), xlab="", ylab=expression(paste("Thickness (mm"^{2},")")), density=c(0,27,200), col=c("grey90","black","grey"), beside=TRUE, axis.lty=1) My question is : how can i adjust the y range from 0,5,10 and 15? for the first barplot and the second to be 0, 2.5 and 5 ? because, even though i put the lim=c(0,15) for the first one, but then it came out as 0,2,4,and so on (with even numbers) and the max is only 14. because also I would like to show "comparisons" of magnitudes with the other baplots /data that I have, one with max 15 and the other with maximum 5) Any help/comments/suggestions are highly appreciated, THanks in advance, cheers, Yakamu [[alternative HTML version deleted]]
Sarah Goslee
2012-Oct-03 18:02 UTC
[R] how can I adjust the ranges of my y-axis in barplot?
Hi, It sounds to me like you want to change the location of the tick marks rather than the axis range (which you've already done). For that see ?axis and its various options for placement and labeling and the yaxt option under ?par to suppress the default axis labels. Sarah On Wed, Oct 3, 2012 at 1:50 PM, Yakamu Yakamu <iam_yakamu at yahoo.com> wrote:> Hi all, > I am making 2 barplots with 3 different bars inside with command : > > bar.wdHo<-barplot(wdHo.mean, names=c(""), cex.lab=1.0, cex.axis=1, cex.names=1, ylim=c(0,15), xlab="", ylab=expression(paste("Thickness (mm"^{2},")")), density=c(0,27,200), col=c("grey90","black","grey"), beside=TRUE, axis.lty=1) > > and the other one : > bar.wdHo<-barplot(wdHo.mean, names=c(""), cex.lab=1.0, cex.axis=1, cex.names=1, ylim=c(0,5), xlab="", ylab=expression(paste("Thickness (mm"^{2},")")), density=c(0,27,200), col=c("grey90","black","grey"), beside=TRUE, axis.lty=1) > > My question is : > > how can i adjust the y range from 0,5,10 and 15? for the first barplot and the second to be 0, 2.5 and 5 ? > because, even though i put the lim=c(0,15) for the first one, but then it came out as 0,2,4,and so on (with even numbers) and the max is only 14. > > because also I would like to show "comparisons" of magnitudes with the other baplots /data that I have, one with max 15 and the other with maximum 5) > > Any help/comments/suggestions are highly appreciated, > THanks in advance, > cheers, > Yakamu >-- Sarah Goslee http://www.functionaldiversity.org
On 03.10.2012 19:50, Yakamu Yakamu wrote:> Hi all, > I am making 2 barplots with 3 different bars inside with command : > > bar.wdHo<-barplot(wdHo.mean, names=c(""), cex.lab=1.0, cex.axis=1, cex.names=1, ylim=c(0,15), xlab="", ylab=expression(paste("Thickness (mm"^{2},")")), density=c(0,27,200), col=c("grey90","black","grey"), beside=TRUE, axis.lty=1) > > and the other one : > bar.wdHo<-barplot(wdHo.mean, names=c(""), cex.lab=1.0, cex.axis=1, cex.names=1, ylim=c(0,5), xlab="", ylab=expression(paste("Thickness (mm"^{2},")")), density=c(0,27,200), col=c("grey90","black","grey"), beside=TRUE, axis.lty=1) >Not reproducible for us ...> My question is : > > how can i adjust the y range from 0,5,10 and 15? for the first barplot and the second to be 0, 2.5 and 5 ? > because, even though i put the lim=c(0,15) for the first one, but then it came out as 0,2,4,and so on (with even numbers) and the max is only 14.You set the range of the whole axis by ylim, if you want to control the tick marks, use: ylim=c(0,15), yaxp=c(0, 15, 3) and ylim=c(0,5), yaxp=c(0, 5, 2) respectively. See ?par for details. Otherwise, omit the y axis via yaxt="n" and add it separately by a call to axis(). Uwe Ligges> > because also I would like to show "comparisons" of magnitudes with the other baplots /data that I have, one with max 15 and the other with maximum 5) > > Any help/comments/suggestions are highly appreciated, > THanks in advance, > cheers, > Yakamu > [[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. >