How do create a plot like pairs in ggplot?

188 views
Skip to first unread message

alexcozzi

unread,
Dec 11, 2008, 2:41:26 PM12/11/08
to ggplot2
I would like to plot a grid of scatterplot like the R command pairs.
Is that possible/easy to do in ggplot2?
thanks

hadley wickham

unread,
Dec 11, 2008, 2:50:50 PM12/11/08
to alexcozzi, ggplot2
Hi Alex,

Have a look at plotmatrix() - it's still a work in progress, but the
basics are there.

Regards,

Hadley
--
http://had.co.nz/

Wayne Folta

unread,
Dec 14, 2008, 1:37:51 PM12/14/08
to ggplot2
Not sure if I'm not yet "thinking ggplot" or what, but this one has me
stumped... I combined two data frames ("a" and "a4") with lattice's
make.groups, and do a density plot:

> head(aa)
when glucose which
a.1 2008-03-04 08:53:00 108 a
a.2 2008-03-04 12:14:00 76 a
a.3 2008-03-04 16:55:00 82 a
a.4 2008-03-04 20:28:00 92 a
a.5 2008-03-04 23:18:00 79 a
a.6 2008-03-05 08:36:00 146 a
> tail(aa)
when glucose which
a4.415 2008-12-12 23:15:00 114 a4
a4.416 2008-12-13 10:17:00 79 a4
a4.417 2008-12-13 13:52:00 108 a4
a4.418 2008-12-13 19:10:00 220 a4
a4.419 2008-12-14 00:19:00 121 a4
a4.420 2008-12-14 09:32:00 81 a4
> qplot (glucose, geom="density", color=which, data=aa) +
scale_colour_manual("Time", breaks=c("a", "a4"), values=c("blue",
"red"), labels=c("Prior", "Current"))

But this doesn't change the key labels in the legend. It does change
the legend name and the colors of the two traces, so the
scale_colour_manual is having some effect, but the labels= isn't. I've
tried with and without the breaks=, and I've even tried putting
incorrect values in breaks= and too many items in labels=, all of
which does not change anything or cause any errors.

Am I just misunderstanding, or is there some kind of problem in that
the density plot features an implicit Y value instead of an explicit
one?

Wayne

hadley wickham

unread,
Dec 14, 2008, 3:37:42 PM12/14/08
to Wayne Folta, ggplot2
Hi Wayne,

> But this doesn't change the key labels in the legend. It does change
> the legend name and the colors of the two traces, so the
> scale_colour_manual is having some effect, but the labels= isn't. I've
> tried with and without the breaks=, and I've even tried putting
> incorrect values in breaks= and too many items in labels=, all of
> which does not change anything or cause any errors.
>
> Am I just misunderstanding, or is there some kind of problem in that
> the density plot features an implicit Y value instead of an explicit
> one?

There's a simple answer - there was a bug in scale_manual where the
labels argument was ignored. I've fixed that bug in the development
version, so it will be fixed in the next release.

Regards,

Hadley

--
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages