niceDensity: Nice density plot

Description Usage Arguments Value Examples

View source: R/nicePlots.R

Description

Nice density plot

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
niceDensity(
  data,
  x,
  fill = NULL,
  weight = 1,
  color = NULL,
  alpha = 0.3,
  bw = NULL,
  xlims = NULL,
  ylims = NULL,
  title = "",
  xlab = x,
  ylab = "density",
  colorname = color,
  fillname = fill,
  colorlabels = NULL,
  filllabels = NULL,
  legendpos = "right"
)

Arguments

data

A dataset

x

horizontal axis variable

weight

Character. Optional variable with weights.

color, fill

Character. Variables to group on. With changing fill or border color

alpha

Opacity of fill color

bw

Numeric. Bandwidth. Controls the smoothness of the plot

xlims, ylims

Numeric vectors of 2 elements. Axis limits

title

Plot title

xlab, ylab

Axis labels. Ylab default: "density"

fillname, colorname

Optional variable names for groups to be displayed on legend

filllabels, colorlabels

Optional labels for grouos to be displayed on legend

legendpos

Legend position. Options: “left”,“top”, “right” (default), “bottom”

Value

A ggplot2-plot

Examples

1
niceDensity(ggplot2::mpg, "displ", bw = 0.2, color = "class", fill = "class")

SZuzek/nicePlots documentation built on Dec. 18, 2021, 12:01 p.m.