cccccccccccccccccc

Page 78

Chapter 12: Graphical procedures

72

> text(x, y, expression(paste(bgroup("(", atop(n, x), ")"), p^x, q^{n-x}))) More information, including a full listing of the features available can obtained from within R using the commands: > help(plotmath) > example(plotmath) > demo(plotmath)

12.2.2 Hershey vector fonts It is possible to specify Hershey vector fonts for rendering text when using the text and contour functions. There are three reasons for using the Hershey fonts: • Hershey fonts can produce better output, especially on a computer screen, for rotated and/or small text. • Hershey fonts provide certain symbols that may not be available in the standard fonts. In particular, there are zodiac signs, cartographic symbols and astronomical symbols. • Hershey fonts provide cyrillic and japanese (Kana and Kanji) characters. More information, including tables of Hershey characters can be obtained from within R using the commands: > > > >

help(Hershey) demo(Hershey) help(Japanese) demo(Japanese)

12.3 Interacting with graphics R also provides functions which allow users to extract or add information to a plot using a mouse. The simplest of these is the locator() function: locator(n, type) Waits for the user to select locations on the current plot using the left mouse button. This continues until n (default 512) points have been selected, or another mouse button is pressed. The type argument allows for plotting at the selected points and has the same effect as for high-level graphics commands; the default is no plotting. locator() returns the locations of the points selected as a list with two components x and y. locator() is usually called with no arguments. It is particularly useful for interactively selecting positions for graphic elements such as legends or labels when it is difficult to calculate in advance where the graphic should be placed. For example, to place some informative text near an outlying point, the command > text(locator(1), "Outlier", adj=0) may be useful. (locator() will be ignored if the current device, such as postscript does not support interactive pointing.) identify(x, y, labels) Allow the user to highlight any of the points defined by x and y (using the left mouse button) by plotting the corresponding component of labels nearby (or


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.