Re: [R] scatter plot using ggplot

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue, 22 Jul 2008 11:30:13 -0500

On Tue, Jul 22, 2008 at 3:42 AM, Megh Dal <megh700004_at_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_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.
Received on Tue 22 Jul 2008 - 16:44:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jul 2008 - 03:32:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive