Dear List Members As a relatively new R user I am extremely glad for there being a nice tool such as ggplot for producing easily nice graphs in R. Now I want to produce graphs with two y-axis. I know that this has been asked a hundred times with respect to standard plots in R. (The answer, to my knowledge, has always been "No" or "No, see the help archive".) But: Is there a more straightforward way IN GGPLOT to draw several lines in one graphs using two different scales and displaying these two scales on the y-axis and the, say, z-axis? Seems to be an obvious extensions of typical plot commands but I can't find any suggestions how to do it. Many thanks for any suggestions or hints. Best, Thorsten -- Dr. Thorsten Vogel Institute for Economic Theory II School of Business and Economics Humboldt-Universit?t zu Berlin Spandauer Str. 1 D-10178 Berlin tel.: +49 (30) 2093 5667 fax: +49 (30) 2093 5696
Thorsten Vogel <thorsten.vogel <at> staff.hu-berlin.de> writes:> Dear List Members > > As a relatively new R user I am extremely glad for there being a nice > tool such as ggplot for producing easily nice graphs in R. Now I want to > produce graphs with two y-axis. I know that this has been asked a > hundred times with respect to standard plots in R. (The answer, to my > knowledge, has always been "No" or "No, see the help archive".) But: Is > there a more straightforward way IN GGPLOT to draw several lines in one > graphs using two different scales and displaying these two scales on the > y-axis and the, say, z-axis? Seems to be an obvious extensions of > typical plot commands but I can't find any suggestions how to do it. > > Many thanks for any suggestions or hints. > > Best, > ThorstenDon't know the answer for ggplot, but just for the record: the answer to the basic-plot question is "(1) not automatically in base R; (2) see the R wiki for commands to do this in base R without two much trouble; (3) see twoord.plot in the plotrix package; (4) there are lots of good reasons not to do this (again see the R wiki)." cheers Ben Bolker
On Tue, Jun 24, 2008 at 3:32 AM, Thorsten Vogel <thorsten.vogel at staff.hu-berlin.de> wrote:> Dear List Members > > As a relatively new R user I am extremely glad for there being a nice tool > such as ggplot for producing easily nice graphs in R. Now I want to produce > graphs with two y-axis. I know that this has been asked a hundred times with > respect to standard plots in R. (The answer, to my knowledge, has always > been "No" or "No, see the help archive".) But: Is there a more > straightforward way IN GGPLOT to draw several lines in one graphs using two > different scales and displaying these two scales on the y-axis and the, say, > z-axis? Seems to be an obvious extensions of typical plot commands but I > can't find any suggestions how to do it.Hi Torsten, As Ben said it's possible to do this with base graphics, but impossible to do this with ggplot2. I'm against this technique because I believe it leads to serious visual distortions and meaningless graphics. If you really want to do it in ggplot2, the only way is to manually rescale the values your self. Hadley -- http://had.co.nz/