[R] ggplot2: deterministic position_jitter & geom_line with position_jitter

meow9th y.yuan at gmx.com
Fri Jun 25 04:06:43 CEST 2010


I'm having the same problem as Stephan (see below), but what I'm trying to
jitter is not a numeric vector, but a factor. How do I proceed? (Naively
jittering a factor makes it numeric, no longer factor, so I don't get the
custom ordering which conveniently comes with using a factor. I'm not sure
how I would simulate that custom ordering with the jittered vector ... I
couldn't find anything online about jittering factors, but maybe I just
wasn't searching cleverly enough.)

Incidentally, the reason I need to synchronize jittering, so to speak, is
because I am using two geom_points to create the effect of a filled circle
with a solid outline but a transparent fill. E.g.,
ggplot(data, aes(x_factor, y_numeric)) + geom_point(shape = 21) +
geom_point(alpha = 0.5)

Is there a more elegant way to accomplish this goal, or is using two
geom_points the way I'm supposed to do it?


hadley wickham wrote:
> 
> On Sat, Sep 12, 2009 at 1:34 PM, Stephan Kolassa <Stephan.Kolassa at gmx.de>
> wrote:
>> Dear guRus,
>>
>> I am starting to work with the ggplot2 package and have two very dumb
>> questions:
>>
>> 1) deterministic position_jitter - the jittering is stochastic; is there
>> any
>> way to get a deterministic jittering? For instance:
> 
> Yes.  The plyr package generally makes this sort of manipulation pain
> free.
> 
>> 2) geom_line with position_jitter - when I call multiple geoms with
>> position_jitter, each geom gets its own jittering. For example
>> (continuing
> 
> Again, you'll have to adding the jittering yourself.
> 
> 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.
> 
> 

-- 
View this message in context: http://r.789695.n4.nabble.com/ggplot2-deterministic-position-jitter-geom-line-with-position-jitter-tp905378p2267909.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list