Label placement with spplot and lattice

The package maptools includes new functions to label points and labels.

Line labelling

The lineLabel function produces and draws text grobs following the paths defined by a list of Line objects. The sp.lineLabel methods use this function to work easily with spplot. Let’s use the meuse data to illustrate how to use it:

Point labelling

This package already provided the pointLabel function with optimization routines to find good locations for point labels without overlaps. This function, useful for base graphics, has been adapted to work with lattice graphics and with the spplot functions.

You will find the panel.pointLabel to use with xyplot and the rest of the lattice family:

You could try the textloc argument. You can choose between ‘constantSlope’,
‘minSlope’ or ‘maxDepth’, and it can also be the numeric index of the location. On the other hand, you may play with different values for spar or with position=’above’ or position=’below’. Take a look at the examples of the help page for details.

Omnia sunt communia!

“As we enjoy great advantages from the inventions of others, we should be glad of an opportunity to serve others by any invention of ours, and this we should do freely and generously”