[R] Regions of significance plots with ggplot2

baptiste auguie baptiste.auguie at googlemail.com
Tue Jun 5 23:10:31 CEST 2012


Hi,

On 6 June 2012 08:58, Paul Murrell <p.murrell at auckland.ac.nz> wrote:
> Hi
>
> Here's one way to approach it ...
>
> ggplot(data.frame(x=1:10, y=1:10)) +
>  geom_polygon(aes(x=xx, y=yy), fill="grey70",
>               data=data.frame(xx=c(0, 0, 4, 4), yy=c(0, 11, 11, 0))) +
>  geom_point(aes(x=x, y=y))
>
> ... (supply a separate data source for the background region polygon).

and note that you can use +/- Inf for convenience,

ggplot(data.frame(x=1:10, y=1:10)) +
  annotate("polygon", x=c(-Inf, -Inf, 4, 4), y=c(-Inf, Inf, Inf, -Inf),
                  fill="grey70", alpha =0.5) +
 geom_point(aes(x=x, y=y))

HTH,

baptiste

>
> Paul
>
> On 4/06/2012 4:18 a.m., Dominic Comtois wrote:
>>
>> I'd like to create a plot similar to this one from Kochanska et al.
>> (Development and Psychopathology, 2011):
>>
>>
>>
>>  <http://pages.videotron.com/do999/r-help/Kochanska_graph_ros.jpg>
>> http://pages.videotron.com/do999/r-help/Kochanska_graph_ros.jpg
>>
>>
>>
>> I am new to ggplot2 and can't see any obvious way to create distinct
>> coloured regions for the background, nor can I find any relevant examples.
>>
>>
>>
>> Any guidance appreciated.
>>
>>
>>
>> DC
>>
>>
>>
>> PS: The context is practically the same as the one from the image (Gene x
>> Environment interaction study). I used the following tool to find the
>> regions of significance, if this is of interest to anyone:
>> <http://www.quantpsy.org/interact/mlr2>
>> http://www.quantpsy.org/interact/mlr2
>>
>>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>
>
> --
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> paul at stat.auckland.ac.nz
> http://www.stat.auckland.ac.nz/~paul/
>
> ______________________________________________
> 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.



More information about the R-help mailing list