# 02 Legible Graphics: R code -- addendum
# Jerzy Wieczorek
# 9/3/15
# 36-721 Statistical Graphics and Visualization
#### A FEW EXTRA PLOTS MADE IN CLASS ####
# Line plots from scatterplot data:
# You could try to plot these raw data as a line
# by setting type = 'l'
# but it won't make sense: they are each a different baby,
# not repeated observations on the same baby.
plot(nhanes$MONTHS, nhanes$LENGTH_CM,
xlab = 'Age (mo)', ylab = 'Length (cm)',
type = 'l')
# Adding points to line plot:
# If we hadn't specified ylim,
# many points would be cut off when we add them with the points command
# since R won't resize the window to accomodate added points
plot(0:6, MeanLengths, type = 'l')
points(nhanes$MONTHS, nhanes$LENGTH_CM)
# Density plot:
# Try different bandwidths (bw),
# analogous to histogram breaks
plot(density(nhanes$LENGTH_CM, bw=3))
plot(density(nhanes$LENGTH_CM, bw=.3))
# Log scales:
# You can plot both x and y axes as log scale
# at the same time, with log = 'xy'
plot(a, b, log = 'xy', las = 1)