Graphics Reference
In-Depth Information
Graphical Layout
heproductionofacomplexplotinvolves positioning multiple elements within mul-
tiple coordinate systems. he arrangement of output within a coordinate system is
typically very explicit; for example, a data symbol is drawn at a precise location and
is a fixed proportion of the plotting region in size. By contrast, the arrangement of
coordinate systems (or entire plots) relative to each other is more implicit. hese ar-
rangementsaremorealongthelinesofanumberofrowsandcolumnsofplots(and
letthesotwarefigureoutexactlywhatthatmeansintermsofthesizeandlocation
of the plots on the page). hese sorts of arrangements have echoes of typesetting or
page-layout operations like those in L A T E X(Lamport, )orHTML(Raggettetal.,
),or even the generation of GUI components such as Java layout managers (Us-
ing Layout Managers, ). It is therefore useful for a statistical graphics system to
provide a means for defining implicit arrangements of elements.
In R there is the concept of a 'layout' (Murrell, )(a simple example was given
inSect. . . ).Alayoutdividesarectangular regionintorowsandcolumns,eachwith
adifferent heightorwidthifdesired.Inthe grid system,aviewportcanbepositioned
relative to a layout rather than via an explicit location and size. For example, the
following code creates a viewport with a layout that defines a central region so that
the margins around the central region are guaranteed to be identical on all sides and
are one quarter of the minimum of the width and height of the central region.
> pushViewport(viewport(layout=grid.layout(3, 3,
widths=c(1, 4, 1),
heights=c(1, 4, 1),
respect=rbind(c(1, 0, 1),
c(0, 0, 0),
c(1, 0, 1)))))
his next code shows another viewport being positioned in the central region of the
layout (Fig. . ). he location and size of this viewport will depend on the size and
shape of the parent viewport that defined the layout.
> pushViewport(viewport(layout.pos.col=2,
layout.pos.row=2))
With the ability to nest viewports, it is possible to specify complex implicit arrange-
ments of graphical elements in R (thisishowthepanelsarearrangedinalattice
plot).
Transformations in Statistical Graphics
Animportant differencebetween transformations inageneralgraphicslanguage and
transformations instatistical sotware isthat statistical sotwaredoesnotapplytrans-
formations to all output. his arises from the difference between statistical graphics
and general graphics images (art). A good example is that in PostScript or SVG the
current transformation applies to text as well as all other shapes. In particular, if the
current transformation scales output, all text is scaled. his is not desirable when
drawing a statistical plot because we would like the text to be readable, so in statisti-
cal graphics, transformations apply to the locations of output and the size of shapes
such as rectangles and lines, but text is sized separately (Fig. . ).
Search WWH ::




Custom Search