Bookmarks for useful graphing tutorials in R.
Types of plots possible with ggplot2
- "Be awesome in ggplot2" - a visually beautiful guide to see what is possible. Great to get ideas for data visualization.
Formatting in general
Themes available for ggplot2 graphs
Modifying color, font, text size in ggplot2
Creating custom themes for ggplot2
Creating custom themes for ggplot2
Add subscripts, Greek letters, and other special characters to graph legends
Useful to add subscripts in axes, e.g. log10(FDR)
Adding annotations to plots
- annotate() function examples to add text at specific x,y locations, gray boxes
- Adding text with partial bolding to the string
- Alternative to main and sub variables in plot() - use mtext() to add text
Formatting x- and y-axes
geom_tile() for matrix data - heatmap
Fix label spacing in ggplot2 with ggrepel -- install.packages("ggrepel")
Use the R package, ggrepel, to add point label text that doesn't overlap.
Use functions ggrepel::geom_label_repel for boxed labels
Use function ggrepel::geom_text_repel for just text, no background
Ideas with ggrepel:
https://stackoverflow.com/questions/15624656/label-points-in-geom-point
Make an animated gif to better see point labels, with ggrepel:
https://mran.microsoft.com/snapshot/2017-02-28/web/packages/ggrepel/vignettes/ggrepel.html
Making a color gradient to label points, and formatting the legend
https://stackoverflow.com/questions/24265652/label-minimum-and-maximum-of-scale-fill-gradient-legend-with-text-ggplot2
Use the R package, ggrepel, to add point label text that doesn't overlap.
Use functions ggrepel::geom_label_repel for boxed labels
Use function ggrepel::geom_text_repel for just text, no background
Ideas with ggrepel:
https://stackoverflow.com/questions/15624656/label-points-in-geom-point
Make an animated gif to better see point labels, with ggrepel:
https://mran.microsoft.com/snapshot/2017-02-28/web/packages/ggrepel/vignettes/ggrepel.html
Making a color gradient to label points, and formatting the legend
https://stackoverflow.com/questions/24265652/label-minimum-and-maximum-of-scale-fill-gradient-legend-with-text-ggplot2
Color code outliers in a box and whisker plot by a specific variable
Formatting legends
Heatmaps
- Heatmap demystified (Ming Tang)
- Understand how to scale data in heatmaps (Ming Tang, "A Tale of Two Heatmaps")
- Triple (three) heatmaps in one figure: once center (XY) and other two at X and Y axis directions (U. R. Bhabuk)
Combining figures
Marginal plots: add histograms or boxplots around the axes to add summarized data
Cowplot R package
Making pdf files
- Compile png images into pdf files: https://jonkimanalyze.wordpress.com/2014/07/24/r-compile-png-files-into-pdf/
- Combine, split, extract pages from pdf files: https://www.r-bloggers.com/2019/04/join-split-and-compress-pdf-files-with-pdftools/
Interactive figures
Ongoing bookmarks. Last edited Aug 4, 2022