density_chart: Create density chart

Description Usage Arguments Details Examples

View source: R/density-chart.R

Description

This function is a convinient overlay for creating a beautiful density plot using ggplot2

Usage

1
2
3
4
density_chart(data, x, group = NULL, title = NULL, sub.title = NULL,
  legend.names = NULL, y.title = NULL, x.title = NULL,
  transparency = 0.3, min.lim = NULL, max.lim = NULL, vline = FALSE,
  vline.custom = NULL, ...)

Arguments

data

data frame containing data for plotting

x

character string specifying name of x variable in data frame

group

character string for grouping of x

title

character string specifying chart title

sub.title

character string specifying chart sub title

legend.names

character string specifying legend names

y.title

character string specifying y-axis title

x.title

character string specifying x-axis title

transparency

numeric setting the level of colour transparency

min.lim

numeric setting minimum limit on x-axis

max.lim

numeric setting maximum limit on x-axis

vline

logical value for drawing vertical lines for the distribution median of x

vline.custom

numeric setting position on vertical line not tied to the distribution of x

Details

Group variable not ideally be a factor but the function will force class factor on the variable.

Use legend names variable to set custom labels on legends. If legend names is NULL the function will force legend names to the colnames of either x or names of groups depending on the input.

The ellipsis is used to pass on arguments to the grey_theme function. Primary use is to specify the legend.position to either "left", "right", "bottom" and "top".

Vline option specifies whether vertical lines showing the median of the distribution should be plotted.

Examples

1
2
density_chart(mtcars, "mpg", "cyl", title = "Miles per gallon",
sub.title = "(per groups of cylinders)", vline = TRUE)

pgarnry/ggplotHelper documentation built on May 25, 2019, 2:54 a.m.