class: center, middle, inverse, title-slide # gg+: paquetes para extender las capacidades de ggplot2 ### Luis D. Verde Arregoitia ### Instituto de EcologÃa A.C. ### 4 de noviembre de 2021 --- <img src="data:image/png;base64,#grammar1.png" width="66%" style="display: block; margin: auto;" /> --- class: center, middle <img src="data:image/png;base64,#gramar2.png" width="86%" style="display: block; margin: auto;" /> --- class: center, middle ```r ggplot(data=lag,aes(x=largo,y=peso,shape=edad))+ geom_point()+ scale_shape_manual(values=c(16,17,16)) ``` --- class:center, middle <img src="data:image/png;base64,#ggmas_files/figure-html/unnamed-chunk-5-1.png" width="504" /> --- class:center, middle ```r ggplot(data=lag,aes(x=largo,y=peso,shape=edad))+ geom_point(size=8)+ scale_shape_manual(values=c(16,17,16))+ theme_minimal(base_size = 22) ``` --- class:center, middle <img src="data:image/png;base64,#ggmas_files/figure-html/unnamed-chunk-7-1.png" width="504" /> --- # labs rótulos para ejes, tÃtulos, subtÃtulos # themes apariencias predefinidas para múltiples parámetros gráficos # fill, shape, color control sobre mapeos estéticos --- class: center <blockquote class="twitter-tweet"><p lang="en" dir="ltr"><a href="https://twitter.com/hashtag/MakingOf?src=hash&ref_src=twsrc%5Etfw">#MakingOf</a> of last week's <a href="https://twitter.com/hashtag/TidyTuesday?src=hash&ref_src=twsrc%5Etfw">#TidyTuesday</a> plot <a href="https://t.co/JGl9tLX2nX">https://t.co/JGl9tLX2nX</a> <a href="https://t.co/Dz7eRxNxuo">pic.twitter.com/Dz7eRxNxuo</a></p>— Georgios Karamanis (@geokaramanis) <a href="https://twitter.com/geokaramanis/status/1437402115186561031?ref_src=twsrc%5Etfw">September 13, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> --- # Extras para `ggplot2` - Gráficos predeterminados, especÃficos a una disciplina - **Paletas de colores** - **geoms** - **Utilidades adicionales** --- class: chapter-slide ## ¿Cuántos paquetes en CRAN comienzan con "gg"? --- ```r p_db <- tools::CRAN_package_db() p_db <- p_db %>% select(Package, Author, Description) ggpkgs <- p_db %>% filter(str_detect(Package, "^gg")) ``` El 04/11/2021: 150 --- ggpmisc, gghalves, ggsolvencyii, gghalfnorm, ggResidpanel, ggseg3d, ggsn, ggVennDiagram, ggThemeAssist, ggcharts, ggROC, ggfx, ggokabeito, gglorenz, ggspatial, ggdark, ggcorrplot, ggpubr, ggnetwork, ggplotify, ggasym, gggap, ggmotif, ggetho, ggm, ggmr, ggplotAssist, ggloop, ggiraphExtra, ggbump, ggallin, ggfittext, ggmulti, ggroups, ggalignment, ggbreak, ggiraph, ggExtra, ggplot.multistats, gghilbertstrings, ggbuildr, ggDCA, ggtern, ggplot2, gggenes, ggimage, ggwordcloud, ggparty, ggrastr, ggseqlogo, gglasso, ggQC, ggBubbles, ggshadow, ggip, ggvenn, ggforce, gglogo, ggmap, ggRandomForests, ggalt, ggenealogy, ggjoy, ggvis, ggmcmc, ggstar, ggpolypath, ggeasy, ggHoriPlot, ggmosaic, ggrepel, gginference, ggx, ggfortify, ggQQunif, ggperiodic, ggfun, ggversa, ggquiver, ggeffects, ggsignif, ggnewscale, ggparallel, ggnormalviolin, ggpval, ggquickeda, ggpointdensity, ggseg, ggfocus, ggdmc, ggh4x, ggpp, gginnards, gglm, ggtikz, ggfan, ggplotgui, ggplotlyExtra, ggPMX, ggplot2movies --- # Demostraciones 1. Paquetes con funciones geom 2. Funciones para acomodar figuras 3. Paletas y herramientas de colores 4. Herramientas útiles --- ## 1. geoms adicionales ### ggforce Accelerating 'ggplot2' ### ggalt Extra Coordinate Systems, 'Geoms', Statistical Transformations, Scales and Fonts for 'ggplot2' ### ggridges Ridgeline Plots in 'ggplot2' --- # ggforce .pull-left[ Thomas Lin Pedersen, https://ggforce.data-imaginist.com/ ] .pull-right[ <img src="data:image/png;base64,#https://raw.githubusercontent.com/thomasp85/ggforce/master/man/figures/logo.png" width="86%" style="display: block; margin: auto 0 auto auto;" /> ] Fns `geom_mark` para agrupar objetos `geom_sina` para mostrar puntos agrupados y la distribución de sus valores --- class: center, middle <img src="data:image/png;base64,#fig2.png" width="86%" style="display: block; margin: auto;" /> --- class: center <img src="data:image/png;base64,#https://luisdva.github.io/assets/images/gghull.png" width="65%" style="display: block; margin: auto;" /> https://luisdva.github.io/Agrupando-puntos/ --- <blockquote class="twitter-tweet"><p lang="en" dir="ltr">For my Intro to Data Science course <a href="https://twitter.com/hashtag/midterm?src=hash&ref_src=twsrc%5Etfw">#midterm</a>, I made a cheat sheet of the <a href="https://twitter.com/hashtag/R?src=hash&ref_src=twsrc%5Etfw">#R</a> package <a href="https://twitter.com/hashtag/ggforce?src=hash&ref_src=twsrc%5Etfw">#ggforce</a>. Any constructive criticism would be much appreciated as I have only been coding for two months. 😬 Help me get better, <a href="https://twitter.com/hashtag/RStats?src=hash&ref_src=twsrc%5Etfw">#RStats</a>! <a href="https://t.co/2SCPCZqb2c">pic.twitter.com/2SCPCZqb2c</a></p>— Amy Jones (@amymarie634) <a href="https://twitter.com/amymarie634/status/1456021661686325248?ref_src=twsrc%5Etfw">November 3, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> --- # `ggalt` Bob Rudis, https://cran.r-project.org/web/packages/ggalt/vignettes/ggalt_examples.html - Distribución de frecuencias (`geom_bkde`) - Agrupar puntos (`geom_encircle`) - LÃneas suavizadas (`geom_xspline`) - Paletas/chupetÃn (`geom_lollipop`) --- <img src="data:image/png;base64,#booker.gif" width="99%" style="display: block; margin: auto;" /> --- # `ggridges` Claus Wilke, https://wilkelab.org/ggridges/articles/introduction.html geoms para comparar distribuciones de valores - `stat="binline"` para histogramas --- <img src="data:image/png;base64,#https://pbs.twimg.com/media/DlOktSPXcAEZiEA.jpg" width="89%" style="display: block; margin: auto;" /> David Smale (https://davidsmale.netlify.app) --- ## 2. Funciones para acomodar figuras ### patchwork The Composer of Plots ### ggh4x Hacks for 'ggplot2' --- # patchwork .pull-left[ Thomas Lin Pedersen, https://patchwork.data-imaginist.com/ ] .pull-right[ <img src="data:image/png;base64,#https://raw.githubusercontent.com/thomasp85/patchwork/master/man/figures/logo.png" width="76%" style="display: block; margin: auto 0 auto auto;" /> ] - Acomodar objetos gráficos (no solo de `ggplot`) y componer figuras complejas - Rótulos, leyendas en común, elementos alineados - `+` para juntar objetos --- <img src="data:image/png;base64,#https://patchwork.data-imaginist.com/articles/guides/assembly_files/figure-html/unnamed-chunk-14-1.png" width="95%" style="display: block; margin: auto;" /> --- ### ggh4x .pull-left[ Teun van den Brand, https://github.com/teunbrand/ggh4x ] .pull-right[ <img src="data:image/png;base64,#https://raw.githubusercontent.com/teunbrand/ggh4x/master/man/figures/logo_300px.png" width="65%" style="display: block; margin: auto 0 auto auto;" /> ] - _Eludiendo la gramática de gráficos_ - Facetas anidadas - Facetas de distintos tamaños --- # 3. Paletas y herramientas de colores ### scico Colour Palettes Based on the Scientific Colour-Maps ### ggnewscale Multiple Fill and Colour Scales in 'ggplot2' --- # scico .pull-left[ Thomas Lin Pedersen, https://github.com/thomasp85/scico/ ] .pull-right[ <img src="data:image/png;base64,#https://raw.githubusercontent.com/thomasp85/scico/master/man/figures/logo.png" width="65%" style="display: block; margin: auto 0 auto auto;" /> ] Implementa paletas de colores diseñandas por Fabio Crameri ([2018](https://www.fabiocrameri.ch/colourmaps/)). - Uniformes (en percepción) - Imprimibles - Aptos para daltónicos - Disponibles con `scale_fill_scico` --- class: center ![](data:image/png;base64,#https://raw.githubusercontent.com/thomasp85/scico/master/man/figures/README-unnamed-chunk-3-1.png) --- # ggnewscale .pull-left[ Elio Campitelli, https://eliocamp.github.io/ggnewscale/ ] .pull-right[ <img src="data:image/png;base64,#https://eliocamp.github.io/ggnewscale/reference/figures/logo.png" width="65%" style="display: block; margin: auto 0 auto auto;" /> ] - Permite usar > 1 escalas (`fill`,`color`) en un mismo gráfico - Util para figuras con varias capas y fuentes de datos --- # 4. Herramientas útiles ### ggrepel Automatically Position Non-Overlapping Text Labels ### gghighlight Highlight Lines and Points in 'ggplot2' --- ### ggeasy Provides a series of aliases to commonly used but difficult to remember 'ggplot2' sequences ### ggfx Filters that can be applied to layers from the 'ggplot2' package --- # ggrepel .pull-left[ Kamil Slowikowski, https://github.com/slowkow/ggrepel ] .pull-right[ <img src="data:image/png;base64,#https://raw.githubusercontent.com/slowkow/ggrepel/master/man/figures/logo.svg" width="65%" style="display: block; margin: auto 0 auto auto;" /> ] - Rótulos que no se enciman --- # gghighlight Hiroaki Yutani https://yutannihilation.github.io/gghighlight/ - Énfasis en elementos gráficos <img src="data:image/png;base64,#https://luisdva.github.io/assets/images/units.png" width="55%" style="display: block; margin: auto;" /> --- # ggeasy .pull-left[ Jonathan Carroll https://jonocarroll.github.io/ggeasy/] .pull-right[ <img src="data:image/png;base64,#https://jonocarroll.github.io/ggeasy/reference/figures/logo.gif" width="65%" style="display: block; margin: auto 0 auto auto;" /> ] - Atajos para modificar parámetros gráficos con `easy_*` - Argumento `teach` para mostrar las modificaciones al código --- # ggfx .pull-left[ Thomas Lin Pedersen, https://ggfx.data-imaginist.com/] .pull-right[ <img src="data:image/png;base64,#https://raw.githubusercontent.com/thomasp85/ggfx/master/man/figures/logo.png" width="65%" style="display: block; margin: auto 0 auto auto;" /> ] - Filtros para elementos gráficos (sombras, brillo, desenfoque) - Aplicados con `with_*` --- class: chapter-slide ## ¡Gracias! @LuisDVerde https://liomys.mx https://maevolab.mx/authors/luis/