Hi:

On Mon, Feb 1, 2010 at 8:05 PM, Chuck White <chuckwhi...@charter.net> wrote:

> Thanks Dennis. That is *exactly* what I am looking for.
>
> Two questions:
> 1. how can I get the markers to be filled? I see that geom_point has a
> property called fill which is the name of a color. Is there a way to get the
> color names from p? I tried to set fill to TRUE hoping it would infer from
> border color but that did not work!
>

fill should insert color into 'open' characters such as triangles, circles
and squares,
but there's nothing to fill with a cross. You also have to use the 'filled'
versions of the
plotting characters, so the revision of the plot call needs to be

 p + geom_point(aes(x = week, y = ind1, colour = id, fill = id), shape = 16,
size = 3) +
     geom_point(aes(x = week, y = ind2, colour = id, fill = id), shape = 17,
size = 3) +
     geom_point(aes(x = week, y = ind3, colour = id, fill = id), shape = 15,
size = 3) +
     geom_point(aes(x = week, y = ind6, colour = id), shape = 4, size = 3)

2. can somebody please point me to a resource/link which talks about setting
> the axes tick marks? In the real application I have 104 data points which I
> would like identified in 4-week increments.
>

scale_x_date()


HTH,
Dennis

>
> Thanks again.
>
> ---- Dennis Murphy <djmu...@gmail.com> wrote:
> > Hi:
> >
> > Try this:
> >
> > Your ind.df didn't include the values, so I redefined it such that it
> > contained all of
> > the data in data.all plus the indicators you set up in ind.df.
> >
> > ind.df <- cbind(data.all[,1:3],ind.df)
> >
> > # Using this ind.df as the data frame, set up the indicators so that all
> you
> > # need to do is call geom_point on each indicator, with its desired
> plotting
> >
> > # character (pch), on top of the base plot p:
> >
> > p <- ggplot(ind.df, aes(x=week, y=value, group=id, colour=id)) +
> > geom_line(size=1.05)
> > p + geom_point(aes(x = week, y = ind1, colour = id), shape = 1, size = 3)
> +
> >     geom_point(aes(x = week, y = ind2, colour = id), shape = 2, size = 3)
> +
> >     geom_point(aes(x = week, y = ind3, colour = id), shape = 22, size =
> 3) +
> >     geom_point(aes(x = week, y = ind6, colour = id), shape = 4, size = 3)
> >
> >
> > Since this question properly belongs on the ggplot2 list, it is being
> cc'ed
> > there as well.
> >
> > HTH,
> > Dennis
> >
> > On Mon, Feb 1, 2010 at 6:06 PM, Chuck White <chuckwhi...@charter.net>
> wrote:
> >
> > > Hello, I am trying to plot time-series data with certain weeks
> highlighted
> > > using symbols.
> > >
> > > require(ggplot2)
> > >
> > > #plotting time series data
> > > timescale <- seq(as.Date("01/01/09","%m/%d/%y"), length.out=12, by=7)
> > > data.all <- data.frame(
> > >    id = c(rep('111',12),rep('222',12),rep('333',12)),
> > >    week=c(timescale,timescale,timescale),
> > >    value=c(rnorm(12,15,3),rnorm(12,30,5),rnorm(12,20,5))
> > > )
> > >
> > > p <- ggplot(data.all, aes(x=week, y=value, group=id, colour=id)) +
> > > geom_line(size=1.05)
> > >
> > > #adding indicators on each line
> > > data.all$ind <-
> > >
> c(rep("",4),rep("2",2),rep("",4),rep("3",2),rep("",2),rep("2",4),rep("",3),rep("6",3),rep("",8),rep("1",4))
> > >
> > > ind.uniq = setdiff(unique(data.all$ind),c(""))
> > > names(ind.uniq) <- paste("ind", ind.uniq, sep="")
> > > ind.df <- data.frame(lapply(ind.uniq, function(x)
> ifelse(data.all$ind==x,
> > > data.all$value, NA)))
> > > ind.df <- cbind(data.all[,c("id","week")],ind.df)
> > >
> > > How can I add markers based on the data in ind.df? In the above
> example,
> > > there are four indicators 1,2,3 and 6.  I'd like to be able to show
> each
> > > using a different shape (circle, triangle, square, cross).
> Additionally, I'd
> > > like to use the same colors for the markers as the lines they are
> plotted
> > > on.
> > >
> > > Thanks.
> > >
> > > ______________________________________________
> > > R-help@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.
> > >
>
>

        [[alternative HTML version deleted]]

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

Reply via email to