Re: [R] Very simple question on plot

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Thu, 13 Dec 2007 08:31:34 -0500

On 12/13/2007 8:16 AM, Ronaldo Reis Junior wrote:
> Hi,
>
> I try to make a plot like this:
>
> Y |
> |
> | o
> | o o
> | o o
> | o o
> |o o o
> |--------------------------------
> 0 10 20 30 40 50 60 70 80 90 100 (A)
> 100 90 80 70 60 50 40 30 20 10 0 (B)
>
> or
> B
> 100 90 80 70 60 50 40 30 20 10 0
> Y |--------------------------------
> |
> | o
> | o o
> | o o
> | o o
> |o o o
> |--------------------------------
> 0 10 20 30 40 50 60 70 80 90 100
> A
>
> A and B are complementary variables.
>
> How is the best way to make this plot?
>

Plot Y versus A, then use the axis() function to add another axis and mtext to label it. For example,

Y <- rnorm(101)
A <- 0:100
plot(A, Y)
B <- 100-A
ticks <- pretty(B)
axis(side=3, at=100-ticks, labels=ticks) mtext("B", side=3, line=3)

You may need to adjust par(mar=) to get large enough margins for some more elaborate versions.

Duncan Murdoch



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 13 Dec 2007 - 13:34:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Dec 2007 - 14:00:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.