[R] ggplot seq

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Fri Jan 23 12:01:47 CET 2009


Dear Felipe,

Provide a dummy sample if your dataset is big or confidential. The
actual values are not that important to figure out what kind of plot you
want.
How did you code Week? Numeric? Try convert it into a factor with levels
= c(27:52, 1:26). And then set the breaks to seq(1, 52, by = 2).

WFBox <- data.frame(Week = rep(1:52, 10), FL = rnorm(520))
WFBox$fWeek <- factor(WFBox$Week, levels = c(27:52, 1:26))
library(ggplot2)
ggplot(WFBox, aes(fWeek, FL)) +
geom_boxplot(outlier.colour="pink",outlier.size=3,outlier.shape=21,fill=
"goldenrod",colour="blue") + scale_x_discrete(breaks=c(seq(1,51,2)))

HTH,

Thierry


------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
Namens Felipe Carrillo
Verzonden: donderdag 22 januari 2009 23:54
Aan: r-help at stat.math.ethz.ch
Onderwerp: [R] ggplot seq

Hi Hadley: Not sure if you received my email, so I am resending it
again.
I have dealt with this before and I can't remember how it got resolved.
It is too much data to reproduce the example below(49.000 records) but
all I am after is trying to get the x axis breaks. I want my x axis to
go from 27 to 51 and 1 to 25 by 2. I am trying to concatenate the breaks
but it sorts the seq() in ascending order. Is there a way to workaround
it? see scale_x_continuous below:

boxP <- ggplot(WFBox, aes(Week, FL,group=Week))
boxP +
geom_boxplot(outlier.colour="pink",outlier.size=3,outlier.shape=21,fill=
"goldenrod",colour="blue") +
scale_x_discrete(breaks=c(seq(27,51,2),seq(1,25,2)))

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA

______________________________________________
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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.




More information about the R-help mailing list