[R] ggplot2

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Fri Jan 23 12:19:43 CET 2009


Dear Vikas,

First a few remarks:
- as we don't have your dataset, your example is not reproducible.
Please do add a (dummy) dataset next time.
- adding spaces makes code much more readable.
- why do you use scale_colour_gradient2 if you set the midpoint at the
lower level? Use scale_colour_gradient instead.
- You will have to tell us what the "desired" labels should look like. 


I tried to figure out what your data looks like an created an example
that works. Let us know if that is what you want.

n <- 20
nPhase <- 5
b3 <- expand.grid(Year = seq_len(n), Phase = runif(nPhase, min = 1, max
= 2))
b3$CDR <- rnorm(nrow(b3))
qplot(Year, CDR, data=b3,colour=Phase, group = Phase,
geom=c("point","line"),legend.position="bottom")
+scale_colour_gradient(limits=c(1,2), low="magenta",
high="darkblue",breaks=c(1,2),labels=c("a","b"))
 


------------------------------------------------------------------------
----
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 Vikas Rawal
Verzonden: donderdag 22 januari 2009 17:59
Aan: r-help at r-project.org
Onderwerp: [R] ggplot2

I have been struggling to get the legends in ggplot2 right or do away
with them altogether (on which I have already sent a post). 

In the following code, the labels argument in the scale_colour_gradient2
does not give me the desired labels in the legend. Could someone
explain?

qplot(Year,CDR,data=b3,colour=Phase,geom=c("point","line"),legend.positi
on="bottom")->p
p+scale_colour_gradient2(limits=c(1,2), midpoint=1,low="magenta",
mid="magenta", high="darkblue",breaks=c(1,2),labels=c("a","b")->p
p

Vikas


	[[alternative HTML version deleted]]

______________________________________________
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