[R] scatter plot using ggplot

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Jul 23 10:59:18 CEST 2008


Dear Megh,

You need to use the ggplot2 package instead of ggplot. Use the size
argument in geom_point() to get bigger circles. Have a look at Hadley's
website for more info (and examples) on ggplot2:
http://had.co.nz/ggplot2/


library(ggplot2)
library(mnormt)
Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2)
x = rmnorm(20, c(0,0), Sigma)
xx = x[order(x[,1]),]
y = xx[,1]
z = xx[,2]
ggplot(data.frame(y,z), aes(y, z)) + geom_point(colour = "blue", size =
6) + scale_x_continuous("x") + opts(title = "x-y plot") 

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 op 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 op r-project.org [mailto:r-help-bounces op r-project.org]
Namens Megh Dal
Verzonden: woensdag 23 juli 2008 4:31
Aan: hadley wickham
CC: r-help op stat.math.ethz.ch
Onderwerp: Re: [R] scatter plot using ggplot

Thanks for this mail. However I am getting following error on that :

Error in inherits(formula, "formula") : could not find function "aes"

And regarding my 3rd query I actually wanted to get "bigger circles" as
points, not intended to increase plot size.

Regards,


--- On Tue, 7/22/08, hadley wickham <h.wickham op gmail.com> wrote:

> From: hadley wickham <h.wickham op gmail.com>
> Subject: Re: [R] scatter plot using ggplot
> To: megh700004 op yahoo.com
> Cc: r-help op stat.math.ethz.ch
> Date: Tuesday, July 22, 2008, 10:00 PM
> On Tue, Jul 22, 2008 at 3:42 AM, Megh Dal
> <megh700004 op yahoo.com> wrote:
> > I used ggplot to create a scatter plot :
> >
> > library(ggplot)
> > library(mnormt)
> > Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2)
> > x = rmnorm(20, c(0,0), Sigma)
> > xx = x[order(x[,1]),]
> > y = xx[,1]
> > z = xx[,2]
> > qplot(z, y, type="point", main="x-y
> plot", xlab="x", col="blue")
> >
> > However I want following:
> >
> > 1. Plot color must be Blue (where it is displaying as
> red)
> > 2. There should not be any color platted
> 
> You can't currently do this with qplot (but will be
> able to in the
> next version).  Use ggplot() instead:
> 
> ggplot(data.frame(y,z), aes(y, z)) +
> geom_point(colour = "blue") +
> scale_x_continuous("x") +
> opts(title = "x-y plot")
> 
> > 3. Plot size must be larger than what it is displacing
> 
> Make the window bigger?
> 
> Hadley
> 
> -- 
> http://had.co.nz/

______________________________________________
R-help op 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.



More information about the R-help mailing list