An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120508/f932c9e8/attachment.pl>
Two Y axes (same scale) in ggplot2 or plot
4 messages · Gary Dong, Duncan Murdoch
On 08/05/2012 3:23 PM, Gary Dong wrote:
Dear R users, I'm plotting housing prices in City A over past 30 years in ggplot2. The Xs are years since 1980. I have two housing price variables: new home prices and old home prices, both of them measured by $/sqft. I have searched related threads on multiple Y axes in ggplot2 and I understand that multiple Y axes in different scales are not possible. I'm wondering if it is possible to have multiple Y axes with the same scale in ggplot2, like in my case. If still not possible, is there a easy way to do it in R's default plot function? Thanks.
In base graphics, you can have as many axes as you like, displaying anything. Use the axis() function. See ?axis for the arguments that determine placement, ticks, etc. I would guess the same flexibility is there in ggplot2, but I don't know how to do it. Duncan Murdoch
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120509/0e6d1283/attachment.pl>
On 09/05/2012 10:46 AM, Gary Dong wrote:
Thanks, Duncan. I tried axis(). It appears it allows you to add an axis, but does not say you can plot a second Y in the graph. Maybe I'm understanding it correctly. Any help will be appreciated!
I don't understand what you want. Could you give an example that comes close, and explain what is wrong with it? Duncan Murdoch
Gary
On Wed, May 9, 2012 at 7:26 AM, Duncan Murdoch
<murdoch.duncan at gmail.com <mailto:murdoch.duncan at gmail.com>> wrote:
On 08/05/2012 3:23 PM, Gary Dong wrote:
Dear R users,
I'm plotting housing prices in City A over past 30 years in
ggplot2. The Xs
are years since 1980. I have two housing price variables: new
home prices
and old home prices, both of them measured by $/sqft. I have
searched
related threads on multiple Y axes in ggplot2 and I understand
that
multiple Y axes in different scales are not possible. I'm
wondering if it
is possible to have multiple Y axes with the same scale in
ggplot2, like in
my case. If still not possible, is there a easy way to do it
in R's default
plot function? Thanks.
In base graphics, you can have as many axes as you like,
displaying anything. Use the axis() function. See ?axis for the
arguments that determine placement, ticks, etc.
I would guess the same flexibility is there in ggplot2, but I
don't know how to do it.
Duncan Murdoch