strange results with position_jitter and facet_grid (timeline plots)

126 views
Skip to first unread message

James Howison

unread,
Dec 2, 2008, 11:52:27 PM12/2/08
to ggp...@googlegroups.com
I'm preparing some timeline plots (thanks to Hadley for getting
scale_x_date rocking with datetime in 0.8 for these!).

I'm seeing strange results when I combine facet_grid and
position_jitter. I'm using geom_jitter to try to cope with over-
plotting (I tried position="dodge" but that didn't seem to have any
effect with geom_point).

With position_jitter & facet_grid (scale and space free):

test-data.csv
ggPlotIllustrativeTasks.r
Picture 8.png
Picture 9.png
Picture 10.png

hadley wickham

unread,
Dec 5, 2008, 8:52:06 AM12/5/08
to James Howison, ggp...@googlegroups.com
Hi James,

That's definitely a bug - I'll add it to my to do list.

Regards,

Hadley
> Without position_jitter (and with facet_grid):
>
>
>
>
> without facet_grid (but with jitter):
>
>
>
>
>
> Basically I'd like the jitter, but with the neat faceting ...
>
> Script and sample data attached. Any ideas?
>
>
>
> (btw, anyone know how to get rid of the Jan-03 label sticking out to
> the left? adjusting lim doesn't seem to help ...)
>
> Thanks,
> James
>
>
>
>



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

James Howison

unread,
Dec 5, 2008, 1:41:19 PM12/5/08
to ggp...@googlegroups.com
Thanks Hadley,

If you are thinking about this thought it worth mentioning that my
ideal representation wouldnt use jitter, but actually use dodge, but
only when there was overplotting. eg:

--------------
A
X D H B
C
--------------

where A, B and C would overwise have overplotted and A.date < B.date <
C.date if A was slightly to the left of B that would be the ultimate!

Clearly there are always going to be issues with overplotting, and
you've done a great job with the options so far.

Event timelines are tricky because they often have large blank
sections and sections with lots of action. Just mentioning this in
case it's easy to implement or something. Realistically I should roll
up my sleeves and help implement geom_timeline() :)

--J

hadley wickham

unread,
Dec 5, 2008, 5:49:29 PM12/5/08
to James Howison, ggp...@googlegroups.com
> If you are thinking about this thought it worth mentioning that my
> ideal representation wouldnt use jitter, but actually use dodge, but
> only when there was overplotting. eg:
>
> --------------
> A
> X D H B
> C
> --------------
>
> where A, B and C would overwise have overplotted and A.date < B.date <
> C.date if A was slightly to the left of B that would be the ultimate!

I suspect you want the dot plots in the attached paper.
Unfortunately, implementing it is non-trivial because you need to know
the size of the plots, which you can't figure that out until the plot
is actually drawn, which means you need to make a new class of grid
grobs, which is non-trivial and something I've been meaning to do for
ages, but haven't yet had a chance.

Regards,

Hadley


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

wilkinson-1999.pdf

James Howison

unread,
Dec 5, 2008, 7:02:08 PM12/5/08
to ggp...@googlegroups.com

Very interesting. I think this is clearly related, although I hadn't
wanted to use it to look at distributions, but more for a combination
of sequential patterns and temporal-clustering.

These graphics are quite close, but overly unwieldy for research
papers and not good for comparing patterns:

http://simile-widgets.googlecode.com/svn/timeline/tags/latest/src/webapp/examples/monet/monet.html

But the dot plots are very close in spirit and the algorithm, I think,
would be basically the same.

--J

James Howison

unread,
Jan 21, 2009, 12:42:14 PM1/21/09
to ggp...@googlegroups.com
*Resurrects thread*

I'm a little confused and think there might have been a regression in
0.8.1 (which I'm using now) (or at least I forgot what I was doing
right before!)

The attached script used to produce a plot where the two facets didn't
have empty lines, but now it acts as it used to producing empty lines
in each facet. I think this is something to do with drop.levels being
needed (I imagine that subset is used somewhere to create the facets,
unused factors are not automatically dropped, one needs to use a
function like this:

# function to drop unused levels after a subset
drop.levels <- function(dat){
dat[] <- lapply(dat, function(x) x[,drop=TRUE])
return(dat)
}

test-data.csv
testRegressionPlot.r
timelineTest.pdf

hadley wickham

unread,
Jan 29, 2009, 11:26:52 AM1/29/09
to James Howison, ggp...@googlegroups.com
Hi James,

Yes that does look like a regression. I'll look into it.

Regards,

Hadley

PS. Sorry for the delay in replying!
> Also I think I used to be able to draw a large white line for each
> horizontal item (to divide the horizontal lines more clearly) using
> geom_hline, but that now doesn't seem to work. I vaguely recall that
> there were some changes here? I think the issue is that I'm using a
> discrete variable in the aes for yintercept?
>
> Expected outcome is three lines in the "fire" facet and four in the
> "gaim" facet, and for each line a large white background line
> (currently a single line is produced at the bottom of each facet).
>
> Any suggestions welcome.
>
> Thanks,
> James
>
> On 5 Dec 2008, at 8:52 AM, hadley wickham wrote:
>
>>
>> --~--~---------~--~----~------------~-------~--~----~
>> You received this message because you are subscribed to the ggplot2
>> mailing list.
>> To post to this group, send email to ggp...@googlegroups.com
>> To unsubscribe from this group, send email to
>> ggplot2+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/ggplot2
>> -~----------~----~----~----~------~----~------~--~---
>>
>
>
>



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

James Howison

unread,
Jan 29, 2009, 11:36:32 AM1/29/09
to hadley wickham, ggp...@googlegroups.com

On 29 Jan 2009, at 11:26 AM, hadley wickham wrote:

> Hi James,
>
> Yes that does look like a regression. I'll look into it.

Cool, happy to test anything.

> Regards,
>
> Hadley
>
> PS. Sorry for the delay in replying!

Don't be, you are extremely responsive already!

hadley wickham

unread,
Jan 31, 2009, 9:06:39 PM1/31/09
to James Howison, ggp...@googlegroups.com
Ok, there's definitely a problem with geom_hline, but don't you want:

facet_grid(project ~ ., scales = "free_y", space = "free")
?

(And what are you trying to achieve with the horizontal line?)

Hadley

On Thu, Jan 29, 2009 at 10:36 AM, James Howison
Reply all
Reply to author
Forward
0 new messages