Graph Gallery

Types of graphs & colour palettes.

  1. There are 19 plot_ functions of 6 broad types in grafify.
  1. Two variables: categorical X and numeric Y

  1. Three or four variables: With either one (plot_3d...) or two (plot_4d_...) categorical X and a numeric Y variable.

  1. Quantitative X-Y & a third variable: plot_xy_NumGroup, plot_xy_CatGroup (new since v0.2.0)

  1. Matched before-after graphs: These are useful for depicting changes in matched data (e.g. matched subjects, randomised blocks etc.) plot_befafter_colours (or plot_befafter_colors) plot_befafter_shapes

  1. Data distributions: plot_qqline, plot_density plot_histogram, and plot_qqmodel (for model residuals)

  1. There are also functions to plot linear models. These can be for assessing the distribution of model residuals with plot_qqmodel or the predictions from the model with plot_lm_model or plot_gam_predict.

Graph customisations

The following arguments can be changed (where available)

  1. Symbol size: adjust symsize or dotsize
  2. Border thickness: adjust symthick or dotthick to change thickness of symbols on the plot
  3. Width: Bar and error bar widths, where available, can be adjusted with bwid and ewid, respectively
  4. Font size: base font size can be changed with fontsize
  5. Violin plots: change trimming to data with trim (TRUE or FALSE) and scaling with scale, which can be "area", "count" or "width".
  6. Opacity: change the alpha parameter to increase transparency of bars or box plots (with b_alpha), violins (v_alpha), symbols (s_alpha) or dots (d_alpha); default set to 1 (i.e. opaque). Reduce alpha to make symbols more transparent when there are overlapping data points.
  7. Colour palettes: set palette from one of the many using ColPal. The choice of colours from within a given palette can be sequential or not (set using ColSeq as TRUE or FALSE). In addition, order of colours can be reversed (with ColRev set to TRUE or FALSE). See colour lists in the vignette on colour palettes.
  8. Text angle: X-axis labels can be rotated 0-90 degrees to prevent overlap of long names using TextXAngle argument.
  9. Jitter: random jitter or scatter of symbols can be set using the jitter argument. When set to 0 there is no jitter (vertically aligned symbols; this is new in v1.4.1).
  10. Colour choice: v2.3.0 onwards, the SingleColour argument can be used to add a single colour to the X variable for all symbols/bars/violins/boxes. Sequential or distant colours are chosen via the ColSeq argument, and colour order reversed with ColRev.

Colour palettes available

All plot_... functions apply the all_grafify colour scheme by default, which can be changed to the following using the ColPal argument.

Also see the Colour Palettes vignettes to use grafify colour schemes with ggplot2 using scale_fill... and scale_colour... functions.

Additional tips

  1. Data should be in the long table format for all plot_ functions (and grafify in general).
  2. The output of all plot_ functions is a ggplot2 object with theme_classic() with base font size of 20. Sizes of graphs and fonts may be system-dependent, increase/decrease as necessary.
  3. plot_ objects and can receive additional layers of geometries, labels, facets, colour schemes, or others, as necessary.
  4. Graphs can be saved using ggsave from ggplot2 package (type ?ggsave for help). Also see suggestions on saving grafify plots here.
  5. All functions come with documentation – use ? (e.g. ?plot_dotbar).
  6. Use table_x_reorder to reorder categorical groups along the X-axis.
  7. Get data summaries with table_summary.