[R] how to use 'points' function to plot two curves with errbar

Yogesh Tiwari yogesh.mpi at googlemail.com
Tue Jun 15 10:20:18 CEST 2010


Dear John,
Great thanks,
I would appreciate if any expert can throw more light on it.

Thanks in advance,

Best Regards,
Yogesh

On 6/14/10, John Kane <jrkrideau at yahoo.ca> wrote:
> Hi Yogesh,
>
> I think you accidentelly replied only to me and not to the mailing list.
> I'd suggest that you copy your post to me to the list to get input from some
> of the
>  real experts.
>
> Currently I don't see any provision for differently coloured error bars in
> the the help page but I easilly could be missing something.
>
> Also you have a fairly busy plot there, you might want to consider having
> the cuves in separate panels.  Perhaps something like this: you can probably
> do this much better in lattice or ggplot but can give you an idea.
> #=========================================================
> x=1:7
> y=6:12
>
> uperror=y+2
> downerror=y-2
>
> opar <- par(mfrow=c(2,2))
> errbar(x,y, uperror, downerror,type="l")
> errbar(x,y, uperror, downerror, type="l")
> errbar(x,y, uperror, downerror, type="l")
> errbar(x,y, uperror, downerror, type="l")
> par(opar)
> #==========================================================
> Also we really should have some sample data., It have to be the entire data
> set or even the real data as
> long as it has the same format and layout.
>
> Have a look at ?dput for  way to include some easily useable data.
>
> Sorrry I'm not more help.
>
> --- On Sun, 6/13/10, Yogesh Tiwari <yogesh.mpi at googlemail.com> wrote:
>
> From: Yogesh Tiwari <yogesh.mpi at googlemail.com>
> Subject: Re: [R] how to use 'points' function to plot two curves with errbar
> To: "John Kane" <jrkrideau at yahoo.ca>
> Received: Sunday, June 13, 2010, 11:21 PM
>
> Dear John,
> Thanks,
> I am using errbar in the package Hmisc,
>
> par(new=TRUE),  worked between two errbar ploting commands but the new
> problem is now 'color of arrow (bars)', its always black for all the four
> curves whereas I have specified separate color for each curve. I want to
> have similar color of  arrow as curve. My command which plots four curves
> and respective errbar subsequently the generated plot is attached herewith.
> Kindly help.
>
>
>> x.val <- as.integer(names(co2mean))
>> errbar(x.val, co2mean, co2mean + co2sd, co2mean - co2sd, xaxt='n',
>> col="black", xlab=NA,ylab=NA)# obs error bar
>> lines(x.val, co2mean, col="black", lwd=2)
>
>
>> par(new=TRUE)
>
>> errbar(x.val, co2tm3.month.mean, co2tm3.month.mean + co2sd.tm3,
>> co2tm3.month.mean - co2sd.tm3, xaxt='n', yaxt='n', col="red",
>> xlab=NA,ylab=NA)# tm3 error bar
>
>> lines(x.val, co2tm3.month.mean, col="red", lwd=2)
>
>> par(new=TRUE)
>
>> errbar(x.val, co2lsce.month.mean, co2lsce.month.mean + co2sd.lsce,
>> co2lsce.month.mean - co2sd.lsce, xaxt='n',yaxt='n', col="green",
>> xlab=NA,ylab=NA)# lsce error bar
>
>> lines(x.val, co2lsce.month.mean, col="green", lwd=2)
>
>> par(new=TRUE)
>
>> errbar(x.val, co2patra1.month.mean, co2patra1.month.mean + co2sd.actm,
>> co2patra1.month.mean - co2sd.actm, xaxt='n',yaxt='n', col="blue",
>> xlab=NA,ylab=NA)# actm error bar
>
>> lines(x.val, co2patra1.month.mean, col="blue", lwd=2)
>
>
>
> Best regards,
> Yogesh
>
>
>
> On Sat, Jun 5, 2010 at 11:36 PM, John Kane <jrkrideau at yahoo.ca> wrote:
>
> The first thing we need to know is what "errbar" are you using?
>
> There are at least two, on in the Hmisc package and one in sfsmisc.
>
>
>  PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained,reproducible code.
>
>
> I'm not sure what you are trying to do here but perhaps looking  at "new" in
> ?par  might hrlp you.
>
> Example:
> plot(1:10, col="red")
> par(new=TRUE)
> plot(10:1, col="blue")
>
>
>
>
>
> --- On Sat, 6/5/10, Yogesh Tiwari <yogesh.mpi at googlemail.com> wrote:
>
>> From: Yogesh Tiwari <yogesh.mpi at googlemail.com>
>
>> Subject: [R] how to use 'points' function to plot two curves with errbar
>> To: r-help at stat.math.ethz.ch
>> Received: Saturday, June 5, 2010, 10:06 AM
>
>
>
>
>> Dear R Users,
>> I am using R on windows.
>>
>> how to use 'points' function to plot two curves with
>> errbar
>>
>> I am doing like:
>>
>> x.val <- as.integer(names(co2mean))
>
>> errbar(x.val, co2mean, co2mean + co2sd, co2mean - co2sd,
>> xaxt='n', col=1,
>> xlab=NA,ylab=NA)# obs error bar
>> lines(x.val, co2mean, col=1, lwd=2)
>>
>> errbar(x.val, co2tm3.month.mean, co2tm3.month.mean +
>
>> co2sd.tm3,
>> co2tm3.month.mean - co2sd.tm3, xaxt='n', col=2,
>> xlab=NA,ylab=NA)# model
>> error bar
>> lines(x.val, co2tm3.month.mean, col=2, lwd=2)
>>
>> Above code replaces first error bar and its line with
>
>> second. Kindly help,
>> how to use 'points' function here so both above can get
>> over ploted
>>
>> Thanks,
>> Regards,
>> Yogesh
>
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>
>> and provide commented, minimal, self-contained,
>> reproducible code.
>>
>
>
>
>
>
> --
> Yogesh K. Tiwari (Dr.rer.nat),
> Scientist,
> Indian Institute of Tropical Meteorology,
>
> Homi Bhabha Road,
> Pashan,
> Pune-411008
> INDIA
>
> Phone: 0091-99 2273 9513 (Cell)
>         : 0091-20-25904350 (O)
> Fax    : 0091-20-258 93 825
>
>
>
>


-- 
Yogesh K. Tiwari (Dr.rer.nat),
Scientist,
Indian Institute of Tropical Meteorology,
Homi Bhabha Road,
Pashan,
Pune-411008
INDIA

Phone: 0091-99 2273 9513 (Cell)
         : 0091-20-25904350 (O)
Fax    : 0091-20-258 93 825



More information about the R-help mailing list