[R] Two x axes - top and bottom

Duncan Mackay dulcalma at bigpond.com
Mon Feb 10 15:06:28 CET 2014

And for the lattice solution


? lattice::print.trellis


Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of David Winsemius
Sent: Monday, 10 February 2014 06:27
To: Benjamin Ward (ENV)
Cc: r-help at r-project.org
Subject: Re: [R] Two x axes - top and bottom

On Feb 8, 2014, at 2:57 PM, Benjamin Ward (ENV) wrote:

> Hi, fellow R users,
> I've been asked to make a plot with two datasets each with a different x
axis, and it's been suggested one be at the top and the other at the bottom
of the graph. I normally use ggplot2, and I know how to plot multiple
datasets by simply + a new geom with a different data option, but usually in
these case my different datasets have had the same x and y axes. Can I add a
new x axis to the top of the plot in ggplot2 or one of the other graphics


x <- qplot(mpg, disp, data = mtcars)
y <- qplot(hp, wt, data = mtcars)

David Winsemius
Alameda, CA, USA

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list