Hi all, Is it possible to change the position of the x axis to have it at the top of the plot when we use the ggplot function ?Thanks for your help,C?line [[alternative HTML version deleted]]
I don't think that is possible with the ggplot2 package. Try lattice or base graphics? --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On December 10, 2014 8:43:47 AM PST, Jouanin Celine <celine_jouanin at yahoo.fr> wrote:>Hi all, >Is it possible to change the position of the x axis to have it at the >top of the plot when we use the ggplot function ?Thanks for your >help,C?line > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.
Hi I do not know ggplot2 well enough to give any advice but as Geff has mention lattice see http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17666.html library(grid) myXlabGrob <- function(...){ ## ...is lab1, lab2, etc # you can add arguments to textGrob for more control in the next line labs <- lapply(list(...), textGrob) nlabs <- length(labs) lab.heights <- lapply(labs, function(lab) unit(1, "grobheight", data = list(lab))) lab.layout <- grid.layout(ncol = nlabs, nrow = 1, heights = do.call(max, lab.heights), widths = unit(1, "null"), respect = TRUE) lab.gf <- frameGrob(layout = lab.layout) for (i in seq_len(nlabs)){ lab.gf <- placeGrob(lab.gf, labs[[i]], row = 1, col = i) } lab.gf } xyplot(1:10 ~ 1:10, scales = list(x = list(alternating = 2)), # puts scale on the top rather than the bottom xlab = "", # removes label at bottom xlab.top = myXlabGrob('B') ) Duncan 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 [mailto:r-help-bounces at r-project.org] On Behalf Of Jouanin Celine Sent: Thursday, 11 December 2014 02:44 To: r-help at r-project.org Subject: [R] x axis position and ggplot2 Hi all, Is it possible to change the position of the x axis to have it at the top of the plot when we use the ggplot function ?Thanks for your help,C?line [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Arnaud Michel
2014-Dec-11 10:12 UTC
[R] to calculate c(rep("1", 43), rep("2",43),...., rep("10",43))
Hello I would like to find an elegant way of calculating c(rep("1", 43), rep("2",43),...., rep("10",43)) Any idea ? Thank you -- Michel ARNAUD DGDRD-Drh - TA 174/04 tel : 04.67.61.75.38 port: 06.47.43.55.31
Rui Barradas
2014-Dec-11 10:34 UTC
[R] to calculate c(rep("1", 43), rep("2", 43), ...., rep("10", 43))
Hello, Try the following. unlist(lapply(1:10, function(n) rep(as.character(n), 43))) Hope this helps, Rui Barradas Em 11-12-2014 10:12, Arnaud Michel escreveu:> Hello > I would like to find an elegant way of calculating > c(rep("1", 43), rep("2",43),...., rep("10",43)) > > Any idea ? > Thank you >
Ivan Calandra
2014-Dec-11 10:38 UTC
[R] to calculate c(rep("1", 43), rep("2", 43), ...., rep("10", 43))
Hi Michel, What about rep(1:10, each=43) If you need to have characters, you could do something like: as.character(1:10) HTH, Ivan -- Ivan Calandra, ATER University of Reims Champagne-Ardenne GEGENA? - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89 ivan.calandra at univ-reims.fr https://www.researchgate.net/profile/Ivan_Calandra Le 11/12/14 11:12, Arnaud Michel a ?crit :> Hello > I would like to find an elegant way of calculating > c(rep("1", 43), rep("2",43),...., rep("10",43)) > > Any idea ? > Thank you >
Hi, Thank you for your answer, I thought we could used something like the "axis" function ( axis(side=3,...)) in ggplot2. I didn't find something like this in ggplot and I'm a bite surprised this doesn't exist. Sometimes we need to use lattice, grid -thank you Duncan for your help, or ggplot or other package, depending on what we want to show and the type of plot. Anyway, as I really need to use the ggplot package, I suppose that I'll plot my data without the axis on the top.Have a nice day, C?line De?: Duncan Mackay <dulcalma at bigpond.com> ??: R <r-help at r-project.org>; 'Jouanin Celine' <celine_jouanin at yahoo.fr> Envoy? le : Jeudi 11 d?cembre 2014 2h57 Objet?: RE: [R] x axis position and ggplot2 Hi I do not know ggplot2 well enough to give any advice but as Geff has mention lattice see http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17666.html library(grid) myXlabGrob <- function(...){ ## ...is lab1, lab2, etc ? # you can add arguments to textGrob for more control? in the next line ? labs <- lapply(list(...), textGrob) ? nlabs <- length(labs) ? lab.heights <- ? lapply(labs, function(lab) unit(1, "grobheight", data = list(lab))) ? lab.layout <- ? grid.layout(ncol = nlabs, nrow = 1, ? ? ? ? ? ? ? ? ? heights = do.call(max, lab.heights), ? ? ? ? ? ? ? ? ? widths = unit(1, "null"), ? ? ? ? ? ? ? ? ? respect = TRUE) ? lab.gf <- frameGrob(layout = lab.layout) ? for (i in seq_len(nlabs)){ ? ? lab.gf <- placeGrob(lab.gf, labs[[i]], row = 1, col = i) ? } ? lab.gf } xyplot(1:10 ~ 1:10, ? ? ? ? scales = list(x = list(alternating = 2)), # puts scale on the top rather than the bottom ? ? ? ? xlab = "", # removes label at bottom ? ? ? ? xlab.top = myXlabGrob('B') ? ? ? ? ) Duncan 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 [mailto:r-help-bounces at r-project.org] On Behalf Of Jouanin Celine Sent: Thursday, 11 December 2014 02:44 To: r-help at r-project.org Subject: [R] x axis position and ggplot2 Hi all, Is it possible to change the position of the x axis to have it at the top of the plot when we use the ggplot function ?Thanks for your help,C?line ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. [[alternative HTML version deleted]]