Skip to content
Back to formatted view

Raw Message

Message-ID: <16059.21262.383939.907239@gargle.gargle.HOWL>
Date: 2003-05-09T07:04:46Z
From: Martin Maechler
Subject: 3 functions on same plot
In-Reply-To: <C2C6EA6C4DADB348BFDF58894B039012012730F4@kinsrv001.dpi.qld.gov.au>

>>>>> "ArnaudD" == Dowkiw, Arnaud <Arnaud.Dowkiw at dpi.qld.gov.au>
>>>>>     on Fri, 9 May 2003 16:30:35 +1000 writes:

    ArnaudD> I'd give the same xlim=c(-a,b) and ylim=(-c,d)
    ArnaudD> parameters to these three functions and then, after
    ArnaudD> each function call
    >> par(new=T)
    ArnaudD> But maybe someone has got a better solution.
 
Yes. One more high-level approach to this is

  matplot(x, cbind(y1,y2,y3), type = "l",  main = "3 curves ...")
and maybe
  legend(...)

See the respective help() pages.
A bit less highlevel with a bit more flexibility is

 plot(x, ..... xlim=.., ylim=.., type = "n")
 lines(x, y1, ........)
 lines(x, y2, ........)
 lines(x, y3, ........)

and legend() again.

Yet another even higher level approach is to work with 
lattice graphics.

Martin

    > -----Original Message----- 
    > From: Joachim Brouwers <joachim.brouwers at gmx.net>
    > Subject: [R] 3 functions on same plot

    > Hello,

    > How can i plot 3 functions (prior, likelihood and
    > posterior) on the same plot?