mk_dotplot: Create a function for making publishable ggplot2 dotplots.

View source: R/mk_dotplot.R

mk_dotplotR Documentation

Create a function for making publishable ggplot2 dotplots.

Description

mk_dotplot takes a data frame as input and returns a function for making dotplots with any continuous variable from the data frame on the x-axis. The dots are stacked along the y axis. The returned faction can also optionally take a grouping variable so that the dots are filled with different colors for different groups.

Usage

mk_dotplot(df)

Arguments

df

A data frame.

Value

function(xvar, fillby = "1", legend_title = fillby, legend_pos = "right", label_size = 3, font_size = 14)

  • xvar. String, name of a continuous variable for x-axis.

  • fillby. String, name of a categorical variable for grouping and coloring each dot. Default = "1", meaning no such variable is supplied.

  • legend_title. String, legend title. Default is the name of the fillby variable.

  • legend_pos. String, legend position. Default = "right".

  • label_size. Integer, size of bar label text. Default = 3.

  • font_size. Overall font size. Default = 14. The font size of the axes and legend text is a fraction of this value.

  • .... Other parameters that can be passed into 'ggplot2::geom_dotplot()'. For example, 'binwidth', which can be specified as a number or a function that calculates width from x. Default is 30 bins, which can be overridden by the supplied 'binwidth' value. Two other common parameters are 'dotsize' and 'stackratio', which controls the size of the dots and the spaces between the dots.

Examples

inst/examples/ex-mk_dotplot.R

gmlang/ezplot documentation built on Sept. 18, 2022, 6:33 a.m.