myVar = seq(-3, 3, .0001) # Set up a variable with .0001 intervals
myNormVar = rnorm(myVar) # Create random normal variable on myVar
png(filename = "illustrations/fig-5-2-kernel density.png",
units = "in", # Set measurements in inches
res = 1200, # Set resolution at 1200dpi
width = 6, # Width at 6 inches
height = 4) # Height at 4 inches
par(mai = c(1, 1, .25, .25)) # Set margins - no Title
plot(density(myNormVar), main = NA) # Density plot of normal variable
polygon(density(myNormVar),
col = "gray") # Fill it in with gray if you want
dev.off() # Output png file
Figure 5-2: A Kernel Density Plot
Portfolio Categories: All Graphics and SGR Book Graphics.