A density plot is a graphical representation of the distribution of data using a smoothed line plot. A simple density plot can be created in R using a combination of the plot and density functions. In the example below, data from the sample "trees" dataset is used to generate a density plot of tree height.
plot( density( NumericVector) )
The resulting plot is very simple. However, users can define arguments to fully customize the appearance of the plot. Each argument is entered within the plot function and separated by a comma. When using the plot / density functions it's often easiest to start with a standard template that lists the most common arguments with a NULL or DEFAULT value (example below). The user can then define whatever arguments they choose to customize the plot.
plot( density (NumericVector),
The format of the above string includes extra returns after each argument. R does not recognize extra returns in a string, the extra returns are included to make visual identification of each argument quicker and easier.
Common Density Plot Arguments
Definitions and examples for a few of the more common arguments are provided in the table below. View the subpages under Data Visualization > Density Plot to learn more about the use of these arguments.