Re: [R] Putting colours in ggplot facets

2021-10-26 Thread Paul Murrell
Sorry, forgot to point out that you would need something like this to install ... remotes::install_github("pmur002/gggrid") Paul On 27/10/2021 12:55 pm, p...@philipsmith.ca wrote: Thanks for this. I was unable to install the gggrid package apparently because it is unavailable for my versio

Re: [R] Putting colours in ggplot facets

2021-10-26 Thread phil
Thanks for this. I was unable to install the gggrid package apparently because it is unavailable for my version of R (4.1.1 (2021-08-10)). But I found it here https://github.com/pmur002/gggrid/releases/tag/v0.1-0, copied the code into your code, and it worked very well. On 2021-10-26 19:18, Pa

Re: [R] Putting colours in ggplot facets

2021-10-26 Thread Paul Murrell
Hi Another alternative (using 'gggrid' to add a 'grid' rect grob as the background), just for the record ... library(gggrid) bgrect <- function(data, coords) { rectGrob(gp=gpar(col=NA, fill=adjustcolor(data$fill[1], alpha=.3))) } ggplot(df, aes(x=date, y=vari)) + grid_panel(bgrect, a

Re: [R] Putting colours in ggplot facets

2021-10-25 Thread phil
Thanks for the suggestions. As it happens, I just a moment ago found a solution. By adding the lines: ct$date <- 1 and ct$vari <- 1 everything works as I want it to. Philip On 2021-10-25 22:37, Ben Tupper wrote: Hi, I don't quite follow what you want to achieve - colored backgrounds for each

Re: [R] Putting colours in ggplot facets

2021-10-25 Thread Ben Tupper
Whoopsie. Misfired cut and paste - all 13 fingers are thumbs today. That second one should be... df <- dplyr::tibble(date,vari,geo,est) %>% dplyr::mutate(colr = paste(geo, est)) ggplot(df,aes(x=date,y=vari))+ geom_rect(aes(fill=colr), xmin=-Inf,xmax=Inf, ymin=-Inf,ym

Re: [R] Putting colours in ggplot facets

2021-10-25 Thread Ben Tupper
Hi, I don't quite follow what you want to achieve - colored backgrounds for each panel? You could RSeek.org for some ideas on how to fish the panels grobs out... https://rseek.org/?q=ggplot+facet+backgound+color https://rseek.org/?q=ggplot+facet+backgound+color I can get sort of close by skipp