Skip to content

plotting a double y axis when x and y lengths differ

4 messages · Vinny Moriarty, michael.weylandt at gmail.com (R. Michael Weylandt, Rolf Turner +1 more

Does plotCI take an xlim argument?

Something like plotCI(..., xlim=range(Data1$Year, Data2$Year))

Michael
On Nov 15, 2011, at 11:51 PM, Vinny Moriarty <vwmoriarty at gmail.com> wrote:

            
#
Any time you use ``par(new=TRUE)'', you're probably doing something
wrong.  Avoid it like the plague.

Following up on Michael Weylandt's post:  plotCI() indeed has an xlim
argument (i.e. the "..." arguments which get passed to plot.default()
can include xlim).

Note that plotCI() also has an ***add*** argument!  Use this,  rather than
mucking about with par(new=TRUE)!

     cheers,

             Rolf Turner
On 16/11/11 17:51, Vinny Moriarty wrote:
#
On 11/16/2011 03:51 PM, Vinny Moriarty wrote:
Hi Vinny,
This is one way to do it:

offset<-0.05
plot(Data1$Year-offset,Data1$Data,type="b",ylim=c(0,110))
points(Data2$Year+offset,Data2$Data,type="b")
dispersion(Data1$Year-offset,Data1$Data,Data1$SE)
dispersion(Data2$Year+offset,Data2$Data,Data2$SE)

Not too elegant, but it gets the job done.

Jim