Hello Everyone, I am trying to overlap a plot with a data set in the form of a data frame. Its very easy to overlap the data using "points" function. But the only problem I am facing is "Standard deviation bar" on the plot. data <- data.frame( x = c(3.00,2.00,3.80,2.40,2.00), error = c(0.0,0.4,1.1,0.7,0.5) ) I tried plotrix, segments but they are making a new plot with data points n error bar. I want to Overlap this data sets on a plot with its Error bar. Can anyone help me with it. Many Thanks, Himanshu -- View this message in context: http://r.789695.n4.nabble.com/Overlapping-a-Plot-with-Dataframe-tp4639396.html Sent from the R help mailing list archive at Nabble.com.
What are you actually plotting? John Kane Kingston ON Canada> -----Original Message----- > From: bioinfo.himanshu at gmail.com > Sent: Tue, 7 Aug 2012 05:57:06 -0700 (PDT) > To: r-help at r-project.org > Subject: [R] Overlapping a Plot with Dataframe > > Hello Everyone, > > I am trying to overlap a plot with a data set in the form of a data > frame. > > Its very easy to overlap the data using "points" function. But the only > problem I am facing is "Standard deviation bar" on the plot. > > data <- data.frame( > x = c(3.00,2.00,3.80,2.40,2.00), > error = c(0.0,0.4,1.1,0.7,0.5) > ) > > I tried plotrix, segments but they are making a new plot with data points > n > error bar. > I want to Overlap this data sets on a plot with its Error bar. > > Can anyone help me with it. > Many Thanks, > Himanshu > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Overlapping-a-Plot-with-Dataframe-tp4639396.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.____________________________________________________________ Receive Notifications of Incoming Messages Easily monitor multiple email accounts & access them with a click. Visit http://www.inbox.com/notifier and check it out!
Hello John, in simple term, I have a Plot as an Output. Now I want to overlap the plot with a Dataframe having error bar. -- View this message in context: http://r.789695.n4.nabble.com/Overlapping-a-Plot-with-Dataframe-tp4639396p4639555.html Sent from the R help mailing list archive at Nabble.com.
On 08/07/2012 10:57 PM, mhimanshu wrote:> Hello Everyone, > > I am trying to overlap a plot with a data set in the form of a data frame. > > Its very easy to overlap the data using "points" function. But the only > problem I am facing is "Standard deviation bar" on the plot. > > data<- data.frame( > x = c(3.00,2.00,3.80,2.40,2.00), > error = c(0.0,0.4,1.1,0.7,0.5) > ) > > I tried plotrix, segments but they are making a new plot with data points n > error bar. > I want to Overlap this data sets on a plot with its Error bar. >Hi Himanshu, Have you tried the following? plot(data$x,ylim=c(1,5)) library(plotrix) dispersion(1:5,data$x,data$error) and "data" is probably not the best name for your data frame. Jim
John Kane Kingston ON Canada> -----Original Message----- > From: bioinfo.himanshu at gmail.com > Sent: Wed, 8 Aug 2012 02:12:00 -0700 (PDT) > To: r-help at r-project.org > Subject: Re: [R] Overlapping a Plot with Dataframe > > Hello John, > > in simple term, I have a Plot as an Output. > Now I want to overlap the plot with a Dataframe having error bar.That's not what the data suggests.> data<- data.frame( > x = c(3.00,2.00,3.80,2.40,2.00), > error = c(0.0,0.4,1.1,0.7,0.5) ) > --seems to imply that you are plotting a vector of a data frame and if Jim is correct you then want to plot error bars on the plot, using the error vector in 'data'. It is just a wording problem but I don't think that you really mean to overlap the plot with another dataframe because you are only showing one data.frame. In any case, assuming Jim's correct his solution works nicely. Another approach is using ggplot--note I have added an x-axis to the data.frame. library(ggplot2) dat<- data.frame( y = c(3.00,2.00,3.80,2.40,2.00), x = 1:5, error = c(0.0,0.4,1.1,0.7,0.5)) limits <- aes(ymax = y + error, ymin=y - error) p <- p <- ggplot(dat , aes( x, y )) + geom_point() + geom_errorbar(limits) p ____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!