Quantcast

Overlapping a Plot with Dataframe

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Overlapping a Plot with Dataframe

mhimanshu
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Overlapping a Plot with Dataframe

John Kane
What are you actually plotting?  

John Kane
Kingston ON Canada


> -----Original Message-----
> From: [hidden email]
> Sent: Tue, 7 Aug 2012 05:57:06 -0700 (PDT)
> To: [hidden email]
> 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.
>
> ______________________________________________
> [hidden email] 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!

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Overlapping a Plot with Dataframe

mhimanshu
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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Overlapping a Plot with Dataframe

Jim Lemon
In reply to this post by mhimanshu
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Overlapping a Plot with Dataframe

mhimanshu
Thanks Jim,

Yes its working now.

Thanks,
Himanshu

On Wed, Aug 8, 2012 at 12:10 PM, Jim Lemon <[hidden email]> wrote:

> 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
>



--
With Regards:

Himanshu
Doctorate Student,
Leibniz Institute for Natural Product Research and Infection Biology e.V.
Hans-Knöll-Institute (HKI)
FSU, Jena
Germany
Contact: 0176 56526087
             0151-63327536
email: [hidden email]

P.S: All good things come to those who wait..!!

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Overlapping a Plot with Dataframe

John Kane
In reply to this post by mhimanshu


John Kane
Kingston ON Canada


> -----Original Message-----
> From: [hidden email]
> Sent: Wed, 8 Aug 2012 02:12:00 -0700 (PDT)
> To: [hidden email]
> 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!

______________________________________________
[hidden email] 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.
Loading...