-----Original Message-----
From: dcarlson at tamu.edu
Sent: Thu, 14 Mar 2013 11:23:18 -0500
To: michael.weylandt at gmail.com, hannah.hlx at gmail.com
Subject: Re: [R] plotting
It is easy to do in base graphics, but probably a bad idea just because
it
is very hard to decode the symbol/color combinations. I added a crude
legend:
# Provide reproducible data
set.seed(42)
value <- round(rnorm(20), 2)
time <- round(runif(20)*10, 1)
group <- sample(1:4)
id <- sample(1:5)
dta <- data.frame(value, time, group, id)
# Plot and legend
plot(value~time, pch=id+20, col=group, bg=group, cex=1.25)
legend("bottomright", as.character(1:4), pch=16,
col=1:4, bty="n", inset=c(0, .045), title="Group")
legend("bottomright", as.character(1:5), pch=21:25, col="gray",
inset=c(.1, 0), bty="n", title="ID")
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of R. Michael Weylandt
Sent: Thursday, March 14, 2013 10:51 AM
To: li li
Cc: r-help
Subject: Re: [R] plotting
I think you'll find this easiest with ggplot2:
library(ggplot2)
ggplot(dat, aes(x = value, y = time, color = group, symbol = id)) +
geom_point()
# symbol = might not be the right argument -- I'm doing this from
memory
or similar....
MW
On Thu, Mar 14, 2013 at 3:46 PM, li li <hannah.hlx at gmail.com> wrote:
Hi alL,
I have a data frame with 4 columns: "value", "time", "group" and
I would like to plot "value" vs. "time" with different colors for
different levels of "group" and
different symbols for different values of "id".
I think I could do this but I would like to see what is an easier
plot
the data this way.
Thank you vey much.
Hanna
[[alternative HTML version deleted]]