[19198] in s-news-athena

home help back first fref pref prev next nref lref last post

[S] Summary: plot two 'y' variables vs. x, with different scales

daemon@ATHENA.MIT.EDU (David Parkhurst)
Sun Sep 12 23:58:53 1999

Message-Id: <000e01befd9b$74795720$1bc74b0c@1hk7i>
From: "David Parkhurst" <parkhurs@ophelia.ucs.indiana.edu>
To: "s-news" <s-news@wubios.wustl.edu>
Date: Sun, 12 Sep 1999 22:51:47 -0500
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit


Recently I asked how to create a plot of two y vectors against one x
vector, when the y's had substantially different ranges.  I wanted one
y axis on the left, and another on the right with different scales.

About ten minutes later, I had an answer from Bill Venables, up there
in Australia.  I've had other replies since---thank you, all---but none
so direct or succinct as his, which was:

It's pretty straightforward, in fact.  Here's one way
> ## (open the graphics device, if necessary)
> x <- 1:10;   y1 <- 1:10;  y2 <- (10:1)*10
> plot(x, y1, type = "l")
> par(new = T)  ## fool it into thinking it has a blank screen
> plot(x, y2, type = "l", axes = F, xlab = "", ylab = "")
> axis(4)
That should do it.

That does do it---thank you.  (But if you have to "fool it," is the 
solution really "straightforward" <g>?)

Dave Parkhurst


-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post