Michael Kubovy
2009-Sep-06 00:03 UTC
[R] ggplot2::qplot() -- arbitary transformations of coordinate system?
Hi, Does anyone know how to do a coord_trans() in which the y-axis is tranformed into (for example) -1000/y? Thanks, _____________________________ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102 Gilmer Hall McCormick Road Charlottesville, VA 22903 Office: B011 +1-434-982-4729 Lab: B019 +1-434-982-4751 Fax: +1-434-982-4766 WWW: http://www.people.virginia.edu/~mk9y/
stephen sefick
2009-Sep-06 01:01 UTC
[R] ggplot2::qplot() -- arbitary transformations of coordinate system?
why not transform the y-data? On Sat, Sep 5, 2009 at 8:03 PM, Michael Kubovy<kubovy at virginia.edu> wrote:> Hi, > > Does anyone know how to do a coord_trans() in which the y-axis is tranformed > into (for example) -1000/y? > > Thanks, > _____________________________ > Professor Michael Kubovy > University of Virginia > Department of Psychology > USPS: ? ? P.O.Box 400400 ? ?Charlottesville, VA 22904-4400 > Parcels: ? ?Room 102 ? ? ? ?Gilmer Hall > ? ? ?McCormick Road ? ?Charlottesville, VA 22903 > Office: ? ?B011 ? ?+1-434-982-4729 > Lab: ? ? ? ?B019 ? ?+1-434-982-4751 > Fax: ? ? ? ?+1-434-982-4766 > WWW: ? ?http://www.people.virginia.edu/~mk9y/ > > ______________________________________________ > 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. >-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
Michael Kubovy
2009-Sep-06 11:30 UTC
[R] ggplot2::qplot() -- arbitary transformations of coordinate system?
Hi Stephen, Because coord_trans() does all the work of plotting the original values on the tranformed scale. See ?coord_trans. To quote: "The difference between transforming the scales and transforming the coordinate system is that scale transformation occurs BEFORE statistics, and coordinate transformation afterwards." # After require(ggplot2) data(diamonds) # Three ways of doing transformating in ggplot: # * by transforming the data qplot(log10(carat), log10(price), data=diamonds) # * by transforming the scales qplot(carat, price, data=diamonds, log="xy") qplot(carat, price, data=diamonds) + scale_x_log10() + scale_y_log10() # * by transforming the coordinate system: qplot(carat, price, data=diamonds) + coord_trans(x = "log10", y = "log10") Michael On Sep 5, 2009, at 9:01 PM, stephen sefick wrote:> why not transform the y-data? > > On Sat, Sep 5, 2009 at 8:03 PM, Michael Kubovy<kubovy at virginia.edu> > wrote: >> Hi, >> >> Does anyone know how to do a coord_trans() in which the y-axis is >> tranformed >> into (for example) -1000/y?> Stephen Sefick_____________________________ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102 Gilmer Hall McCormick Road Charlottesville, VA 22903 Office: B011 +1-434-982-4729 Lab: B019 +1-434-982-4751 Fax: +1-434-982-4766 WWW: http://www.people.virginia.edu/~mk9y/
hadley wickham
2009-Sep-06 14:12 UTC
[R] ggplot2::qplot() -- arbitary transformations of coordinate system?
Hi Michael, You could use aes(y = 1000 * myyvar) and coord_trans(trans_y = "inverse") Hadley On Sun, Sep 6, 2009 at 6:30 AM, Michael Kubovy<kubovy at virginia.edu> wrote:> Hi Stephen, > > Because coord_trans() does all the work of plotting the original values on > the tranformed scale. See ?coord_trans. To quote: "The difference between > transforming the scales and transforming the coordinate system is that scale > transformation occurs BEFORE statistics, and coordinate transformation > afterwards." > > # After > require(ggplot2) > data(diamonds) > # Three ways of doing transformating in ggplot: > # * by transforming the data > qplot(log10(carat), log10(price), data=diamonds) > # * by transforming the scales > qplot(carat, price, data=diamonds, log="xy") > qplot(carat, price, data=diamonds) + scale_x_log10() + scale_y_log10() > # * by transforming the coordinate system: > qplot(carat, price, data=diamonds) + coord_trans(x = "log10", y = "log10") > > Michael > > On Sep 5, 2009, at 9:01 PM, stephen sefick wrote: > >> why not transform the y-data? >> >> On Sat, Sep 5, 2009 at 8:03 PM, Michael Kubovy<kubovy at virginia.edu> wrote: >>> >>> Hi, >>> >>> Does anyone know how to do a coord_trans() in which the y-axis is >>> tranformed >>> into (for example) -1000/y? > >> Stephen Sefick > > > > _____________________________ > Professor Michael Kubovy > University of Virginia > Department of Psychology > USPS: ? ? P.O.Box 400400 ? ?Charlottesville, VA 22904-4400 > Parcels: ? ?Room 102 ? ? ? ?Gilmer Hall > ? ? ?McCormick Road ? ?Charlottesville, VA 22903 > Office: ? ?B011 ? ?+1-434-982-4729 > Lab: ? ? ? ?B019 ? ?+1-434-982-4751 > Fax: ? ? ? ?+1-434-982-4766 > WWW: ? ?http://www.people.virginia.edu/~mk9y/ > > ______________________________________________ > 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. >-- http://had.co.nz/
David Winsemius
2009-Sep-06 14:46 UTC
[R] ggplot2::qplot() -- arbitary transformations of coordinate system?
Is there a place to find a list of the legal values for the coord_trans parameters. I spent a bunch of time searching the ggplot2 docs and r-help for same without success. I also made an attempt at looking at the code in R which also failed. -- David. On Sep 6, 2009, at 10:12 AM, hadley wickham wrote:> Hi Michael, > > You could use aes(y = 1000 * myyvar) and coord_trans(trans_y = > "inverse") > > Hadley > > On Sun, Sep 6, 2009 at 6:30 AM, Michael Kubovy<kubovy at virginia.edu> > wrote: >> Hi Stephen, >> >> Because coord_trans() does all the work of plotting the original >> values on >> the tranformed scale. See ?coord_trans. To quote: "The difference >> between >> transforming the scales and transforming the coordinate system is >> that scale >> transformation occurs BEFORE statistics, and coordinate >> transformation >> afterwards." >> >> # After >> require(ggplot2) >> data(diamonds) >> # Three ways of doing transformating in ggplot: >> # * by transforming the data >> qplot(log10(carat), log10(price), data=diamonds) >> # * by transforming the scales >> qplot(carat, price, data=diamonds, log="xy") >> qplot(carat, price, data=diamonds) + scale_x_log10() + >> scale_y_log10() >> # * by transforming the coordinate system: >> qplot(carat, price, data=diamonds) + coord_trans(x = "log10", y = >> "log10") >> >> Michael >> >> On Sep 5, 2009, at 9:01 PM, stephen sefick wrote: >> >>> why not transform the y-data? >>> >>> On Sat, Sep 5, 2009 at 8:03 PM, Michael >>> Kubovy<kubovy at virginia.edu> wrote: >>>> >>>> Hi, >>>> >>>> Does anyone know how to do a coord_trans() in which the y-axis is >>>> tranformed >>>> into (for example) -1000/y? >> >>> Stephen Sefick >> >> >> >> _____________________________ >> Professor Michael Kubovy >> University of Virginia >> Department of Psychology >> USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 >> Parcels: Room 102 Gilmer Hall >> McCormick Road Charlottesville, VA 22903 >> Office: B011 +1-434-982-4729 >> Lab: B019 +1-434-982-4751 >> Fax: +1-434-982-4766 >> WWW: http://www.people.virginia.edu/~mk9y/ >> >> ______________________________________________ >> 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. >> > > > > -- > http://had.co.nz/ > > ______________________________________________ > 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.David Winsemius, MD Heritage Laboratories West Hartford, CT
hadley wickham
2009-Sep-12 15:43 UTC
[R] ggplot2::qplot() -- arbitary transformations of coordinate system?
> Is there a place to find a list of the legal values for the coord_trans > parameters. I spent a bunch of time searching the ggplot2 docs and r-help > for same without success. I also made an attempt at looking at the code in R > which also failed.In the book, or with apropos("^Trans", ignore = F) Hadley -- http://had.co.nz/