Graphics Programs Reference
In-Depth Information
No need to stop here though. You can plot the histogram and density plot
together to get the exact frequencies represented by the bars and the
estimated proportions from the curve, as shown in Figure 6-31. Use the
histogram() (from the lattice package) and lines() functions. The former
creates a new plot whereas the latter adds lines to an existing plot.
library(lattice)
histogram(birth$X2008, breaks=10)
lines(d2008)
FIGurE 6-31 Histogram and density plot combined
So there's a lot you can do and plenty of variations, but the math and
geometry are still the same as the old-school stem-and-leaf plot. You're
counting, aggregating, and grouping. The best variation can vary based
on what data you have. Figure 6-32 shows a more finished graphic. I de-
emphasized the axis lines, rearranged the labels, and added a pointer for
median. The vertical axis, which represents density, isn't especially use-
ful in this graphic, but I left it in there for the sake of completeness.
Search WWH ::




Custom Search