Using traditional graphics you probably want to look at

?lines, ?points, ?text . . . 

These allow you to add to your plot without calling new axes.

For custom axes:

plot(1:10, 1:10, axes=FALSE)
lines(1:10, 10:1)
points(1:10, runif(10, 2, 5), col=1, pch=21, bg=3, cex=3)
axis(1, at=1:10)
axis(3, at=1:10, lab=10:1)
axis(2)
box()

Look  at ?axis for details.

--Matt


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Michael
Sent: Sunday, January 29, 2006 8:49 PM
To: [EMAIL PROTECTED]
Cc: [email protected]
Subject: Re: [R] How to add two different axis to one plot?


No this is not good.

When I used par(new=TRUE), it does not adjust axis accordingly...

Thus two different axes end up overlap together.

For example, if my first plot has x-axis from 0 to 10, with ticks at 1, 3,
5, 7, 9;

and my second plot has x-axis from 2 to 12, with ticks at 2, 2.9, 5.5...

then the two plots have two different axes with ticks overlap together.

The visual appearance is very bad.

On 1/29/06, Andrew Robinson <[EMAIL PROTECTED]> wrote:
>
> Use the axis() command to add custom axes.
>
> To "hold" the plot, insert
>
> par(new=TRUE)
>
> between the plot statements, thus:
>
> plot(x1, y1, etc ...)
> par(new=TRUE)
> plot(x2, y2, etc ...)
>
>
>
> Andrew
>
> On Mon, January 30, 2006 2:49 pm, Michael said:
> > Hi all,
> >
> > I need to put two different axis to one plot. On the top of the plot, I
> > need
> > to put one axis, with increments from left side to the right side; then
> at
> > the bottom of the same plot, I need to put another axis, with increments
> > from right side to the left side and showing a different unit. How do I
> do
> > that?
> >
> > By the way, is there a "hold" command for plotting?
> >
> > If I first plot a picture, how to add another "plot" command onto it
> > without
> > erasing it?
> >
> > In matlab, it can be convinient done by "hold on" and "hold off"... and
> > can
> > I do it in R?
> >
> > Thanks a lot,
> >
> > Micheal
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [email protected] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
>
>
> Andrew Robinson
> Senior Lecturer in Statistics                       Tel: +61-3-8344-9763
> Department of Mathematics and Statistics            Fax: +61-3-8344 4599
> University of Melbourne, VIC 3010 Australia
> Email: [EMAIL PROTECTED]    Website:
> http://www.ms.unimelb.edu.au
>
>

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to