Skip to content

Instantly share code, notes, and snippets.

@davebraze
Last active June 28, 2019 17:40
Show Gist options
  • Save davebraze/2d55fa63ccc4edb624f7b6ebb6351b19 to your computer and use it in GitHub Desktop.
Save davebraze/2d55fa63ccc4edb624f7b6ebb6351b19 to your computer and use it in GitHub Desktop.
ggplot2 tools and techniques

Intro

ggrepel::

https://cran.r-project.org/web/packages/ggrepel/

"Provides text and label geoms for 'ggplot2' that help to avoid overlapping text labels.

ggforce::

https://cran.r-project.org/web/packages/ggforce/

"The aim of 'ggplot2' is to aid in visual data investigations. This focus has led to a lack of facilities for composing specialised plots. 'ggforce' aims to be a collection of mainly new stats and geoms that fills this gap

patchwork::

https://github.com/thomasp85/patchwork

"The goal of patchwork is to make it ridiculously simple to combine separate ggplots into the same graphic. As such it tries to solve the same problem as gridExtra::grid.arrange() and cowplot::plot_grid but using an API that incites exploration and iteration."

ggThemeAssist::

https://cran.r-project.org/web/packages/ggThemeAssist/

Rstudio add-in that delivers a graphical interface for editing 'ggplot2' theme elements.

ggpubr::

https://cran.r-project.org/web/packages/ggpubr/

help with labeling stats, fine tuning formatting: "easy(er)-to-use functions for creating and customizing 'ggplot2'- based publication ready plots."

gghighlight::

https://cran.r-project.org/web/packages/gghighlight/vignettes/gghighlight.html

Tools to select and highlight curves and points in plots.

ggfittext::

https://cran.r-project.org/web/packages/ggfittext/

For autoscaling text annotations.

egg::

https://cran.r-project.org/web/packages/egg/

Miscellaneous post-processing/formatting tools: "adjust layouts and allow alignment between plot panels, as well as setting panel sizes to fixed values"

directlabels::

https://cran.r-project.org/web/packages/directlabels/

"framework for automatically placing direct labels onto multicolor 'lattice' or 'ggplot2' plots. Label positions are described using Positioning Methods which can be re-used across several different plots."

lemon::

https://cran.r-project.org/web/packages/lemon/index.html

Allows faceting with axis labels on all facets.

scales::

https://cran.r-project.org/web/packages/scales/

Graphical scales map data to aesthetics, and provide methods for automatically determining breaks and labels for axes and legends. Lots of help with formatting equations in labels and axes.

cowplot::

https://cran.r-project.org/web/packages/cowplot/

"Makes it easy to combine multiple 'ggplot2' plots into one and label them with letters, e.g. A, B, C, etc., as is often required for scientific publications. The package also provides a streamlined and clean theme that is used in the Wilke lab"

bbplot::

https://github.com/bbc/bbplot

"create and export ggplot2 charts in the style used by the BBC News data team"

extrafont::

https://cran.r-project.org/web/packages/extrafont/

Usage details here: https://github.com/wch/extrafont

Not specific to ggplot2, but provides "ools to using fonts other than the standard PostScript fonts. This package makes it easy to use system TrueType fonts and with PDF or PostScript output files, and with bitmap output files in Windows. extrafont can also be used with fonts packaged specifically to be used with, such as the fontcm package, which has Computer Modern PostScript fonts with math symbols."

colorspace::, RColorBrewer::, scico::, viridis::

All general purpose packages for working with color palettes. None are specific to ggplot2. Scico and viridis are more opinionated; colorspace and RColorBrewer are more general.

https://cran.r-project.org/web/packages/colorspace/

https://cran.r-project.org/web/packages/RColorBrewer/index.html

https://cran.r-project.org/web/packages/scico/index.html

https://cran.r-project.org/web/packages/viridis/index.html

english::

https://cran.r-project.org/web/packages/english/index.html

"Convert numbers to an English language version, one, two, three, ... Ordinals are also available, first, second, third, ..."

Useful especially for Notes, captions, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment