Easily add direct labels to plots using the directlabels package

This package is an attempt to make direct labeling a reality in
everyday statistical practice by making available a body of useful
functions that make direct labeling of common plots easy to do with
high-level plotting systems such as lattice and ggplot2. The main
function that the package provides is direct.label(p), which
takes a lattice or ggplot2 plot p and adds direct labels:

Can I increase text size? Yes, but do it before calling
Positioning Methods that calculate the label bounding
box: direct.label(p, list(cex=2, "last.qp")) for a lineplot p.

Why are some labels small when using lineplot labeling methods
like last.polygons?
Because the labels are automatically resized to fit in the plotting
area. To increase the text size you can increase the x axis limits as in
the lars
and ridge
examples.

How to adjust all labels left or right? For example you can
use direct.label(p, list(dl.trans(x=x+0.1), "last.qp")) to
move labels to the right 0.1cm and then
apply last.qp
for a lineplot p.

How
about fontface, fontfamily, rot, alpha
text parameters? See example(dlcompare).

How about direct labeling aesthetics other than colour in ggplot2?
See example(geom_dl).

Positioning Methods specify the direct label positions

Direct labeling a plot can be decomposed into 2 steps: calculating
label positions, then drawing the labels. For the first step, the
directlabels package introduces the concept of the Positioning Method,
which is a list that specifies how to transform the data points into
labels. For example, with the scatterplot above, the default
Positioning Method is
smart.grid,
which places each label close to the center of the corresponding point
cloud. The following diagram shows how the data to plot is converted
to standard form column names and positions in centimeters before the
Positioning Method is applied:

If default label positions are not satisfactory, you can always
specify your own Positioning Method, using the method=
argument to direct.label. For example, we can label
longitudinal data either on the left or right of the lines:

first.qp and last.qp are the names of Positioning
Methods which place the labels respectively near the first or last
points, ensuring that the labels do not overlap and so are
readable. To find out which built-in Positioning Methods are
appropriate for your plot, check out the
Positioning Methods example database.

However, the power of the directlabels system is the fact that you
can write your own Positioning Methods,
and they can be reused for different plots. So once you write a
Positioning Method that works, adding direct labels in everyday plots
is as simple as calling direct.label, no matter if you are
using lattice or ggplot2.

Talks, links, etc.

Adding direct
labels to
plots, Best
Student Poster at useR 2011, attempts to motivate the package and
explain how it works
[source]. Notably,
the "Optimal Labels" section is basically the only documentation of
how to implement
the qp.labels
Positioning Method. The details of the "Modular package design"
section have changed in version 2.0. Rather than
calling label.positions the first time the plot
is printed, we now draw a dlgrob
whose drawDetails method calculates label positions every
time the plot window is resized/redrawn.