[R] ggplot2, geom_hline and facet_grid
Small Sandy (NHS Greater Glasgow & Clyde)
sandy.small at nhs.net
Wed Jan 19 22:30:00 CET 2011
Hi
Still having problems in that when I use geom_hline and facet_grid together I get two extra empty panels
A reproducible example can be found at:
https://gist.github.com/786894
Sandy Small
________________________________________
From: h.wickham at gmail.com [h.wickham at gmail.com] On Behalf Of Hadley Wickham [hadley at rice.edu]
Sent: 19 January 2011 15:11
To: Small Sandy (NHS Greater Glasgow & Clyde)
Cc: r-help at r-project.org
Subject: Re: [R] ggplot2, geom_hline and facet_grid
Hi Sandy,
It's difficult to know what's going wrong without a small reproducible
example (https://github.com/hadley/devtools/wiki/Reproducibility) -
could you please provide one? You might also have better luck with an
email directly to the ggplot2 mailing list.
Hadley
On Wed, Jan 19, 2011 at 2:57 AM, Sandy Small <sandy.small at nhs.net> wrote:
> Having upgraded to R version 2.12.1 I still have the same problem:
>
> The combination of facet_grid and geom_hline produce (for me) 4 panels
> of which two are empty of any data or lines (labelled "1" and "2").
> Removing either the facet_grid or the geom_hline gives me the result I
> would then expect.
>
> I have tried forcing the rhythm to be a factor
> Anyone have any ideas?
>
> Sandy
>
> Dennis Murphy wrote:
>
> Hi:
>
> The attached plot comes from the following code:
>
> g <- ggplot(data =f, aes(x = (variable_time + fixed_time)/2, y
> variable_time - fixed_time))
> g + geom_point() + geom_hline(yintercept =) + facet_grid(ecd_rhythm ~ .)
>
> Is this what you were expecting?
>
> > sessionInfo()
> R version 2.12.1 Patched (2010-12-18 r53869)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=glish_United States.1252
> [2] LC_CTYPE=glish_United States.1252
> [3] LC_MONETARY=glish_United States.1252
> [4] LC_NUMERIC=nbsp;
> [5] LC_TIME=glish_United States.1252
>
> attached base packages:
> [1] splines stats graphics grDevices utils datasets
> grid
> [8] methods base
>
> other attached packages:
> [1] data.table_1.5.1 doBy_4.2.2 R2HTML_2.2 contrast_0.13
> [5] Design_2.3-0 Hmisc_3.8-3 survival_2.36-2 sos_1.3-0
> [9] brew_1.0-4 lattice_0.19-17 ggplot2_0.8.9 proto_0.3-8
> [13] reshape_0.8.3 plyr_1.4
>
> loaded via a namespace (and not attached):
> [1] cluster_1.13.2 digest_0.4.2 Matrix_0.999375-46
> reshape2_1.1
> [5] stringr_0.4 tools_2.12.1
>
> HTH,
> Dennis
>
> On Tue, Jan 18, 2011 at 1:46 AM, Small Sandy (NHS Greater Glasgow &
> Clyde) <sandy.small at nhs.net <ailto:sandy.small at nhs.net%22>> wrote:
>
> Hi
>
> I have a long data set on which I want to do Bland-Altman style
> plots for each rhythm type
> Using ggplot2, when I use geom_hline with facet_grid I get an
> extra set of empty panels.
> I can't get it to do it with the "Diamonds" data supplied with
> the package so here is a (much abbreviated) example:
>
> > lvexs
> cvd_basestudy ecd_rhythm fixed_time variable_time
> 1 CBP05J02 AF 30.9000 29.4225
> 2 CBP05J02 AF 33.1700 32.0350
> 3 CBP05J02 AF 32.5700 30.2775
> 4 CBP05J02 AF 32.0550 33.7275
> 5 CBP05J02 SINUS 30.9175 28.3475
> 6 CBP05J02 SINUS 30.5725 29.7450
> 7 CBP05J02 SINUS 33.0000 31.1550
> 9 CBP05J02 SINUS 31.8350 30.7000
> 10 CBP05J02 SINUS 34.0450 33.4800
> 11 CBP05J02 SINUS 31.3975 29.8150
> > qplot((variable_time + fixed_time)/2, variable_time -
> fixed_time, data=exs) + facet_grid(ecd_rhythm ~ .) +
> geom_hline(yintercept=0)
>
> If I take out the geom_hline I get the plots I would expect.
>
> It doesn't seem to make any difference if I get the mean and
> difference separately.
>
> Can anyone explain this and tell me how to avoid it (and why
> does it work with the Diamonds data set?
>
> Any help much appreciated - thanks.
>
> Sandy
>
> Sandy Small
> Clinical Physicist
> NHS Forth Valley
> and
> NHS Greater Glasgow and Clyde
>
>
>
> ********************************************************************************************************************
>
> This message may contain confidential information. If yo...{{dropped:21}}
>
> ______________________________________________
> 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.
>
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
********************************************************************************************************************
This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.
Thank you for your co-operation.
NHSmail is the secure email and directory service available for all NHS staff in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and GSi recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
For more information and to find out how you can switch, visit www.connectingforhealth.nhs.uk/nhsmail
More information about the R-help
mailing list