Graphics Reference
In-Depth Information
(inverting the opacity) of the legend and using a Porter-Duff (Porterand Duff, )
'out' compositing operator to create a 'hole' for the legend within the plot (Fig. . ).
Arranging Plots
3.2.2
Where several plots are produced together on a page, a new set of free parameters
becomes available, corresponding to the location and size of each complete plot. It is
important that statistical graphics sotware provides some way to specify an arrange-
ment of several plots.
In R,itiseasytoproduceanarrayofplotsallofthesamesize,asshownbythe
code below.
> par(mfrow=c(2, 2))
It is also possible to produce arrangements where plots have different sizes. he fol-
lowing code gives a simple example (Fig. . ):
> layout(rbind(c(1, 2),
c(0, 0),
c(3, 3)),
heights=c(1.5, lcm(0.5), 1))
heideaofarranging several plotscanbegeneralized tothearrangement ofarbitrary
graphical elements; we will discuss this more in Sect. . .
Annotation
3.2.3
Amore complex sort of customization involves the addition of further graphical out-
put to a plot. For example, it can be useful to add an informative label to one or more
data symbols in a plot.
Graphical Primitives
he first requirement for producing annotations is the ability to produce very basic
graphical output, such as simple text labels. In this way, statistical graphics sotware
needs to be able to act like a generic drawing program, allowing the user to draw
lines, rectangles, text and so on. In other words, it is not good if the sotware can
'only' draw complete plots.
In R, there are functions for drawing a standard set of graphical primitives. he
following code demonstrates how rectangles, lines, polygons and text can be added
to a basic plot (Fig. . ):
> x <- rnorm(20)
> plot(x)
> polygon(c(1, 1:20, 20), c(0, x, 0),
col="grey", border=NA)
> rect(1, -0.5, 20, 0.5,
col="white", lty="dotted")
> lines(x)
> points(x, pch=16)
> text(c(0.7, 20.3), 0, c("within", "control"), srt=90)
Search WWH ::




Custom Search