Abstract

The R graphics engine has new support for drawing complex paths via the functions polypath() and grid.path(). This article explains what is meant by a complex path and demonstrates the usefulness of complex paths in drawing non-trivial shapes, logos, customised data symbols, and maps. One of the design goals of the R graphics system (R Development Core Team, 2011) is to allow fine control over the small details of plots. One way that the R graphics system does this is by providing access to low-level generic graphics facilities, such as the ability to draw basic shapes and the ability to control apparently esoteric, but still useful, features of those shapes, such as the line end style used for drawing lines. In R version 2.12.0, another low-level graphics facility was added to R: the ability to draw complex paths (not just polygons). This article describes this new facility and presents some examples that show how complex paths might be useful. Drawing paths with holes The concept of a path is similar to the concept of a polygon: a path is defined by a series of (x,y) locations that describe the boundary of the path. For example, the following code defines a set of (x,y) locations that describe a simple triangle. > x y <c(.1, .8, .1) A triangle can be drawn from these locations using either the polypath() function from the graphics package or, as shown below and in Figure 1, using the grid.path() function from the grid package.

Highlights

  • Drawing paths with holesThe concept of a path is similar to the concept of a polygon: a path is defined by a series of (x, y) locations that describe the boundary of the path

  • One of the design goals of the R graphics system is to allow fine control over the small details of plots

  • As for any basic shape, it is possible to control the colour and thickness of the path border and the colour used to fill the interior of the path

Read more

Summary

Drawing paths with holes

The concept of a path is similar to the concept of a polygon: a path is defined by a series of (x, y) locations that describe the boundary of the path. A triangle can be drawn from these locations using either the polypath() function from the graphics package or, as shown below and, using the grid.path() function from the grid package. These locations can be used to describe a path that consists of two distinct triangles. This output looks exactly the same as the output we would get from drawing the two groups of locations as polygons, using grid.polygon() or polygon(), but conceptually there is a difference because the path treats the two groups of locations as defining a single shape. We can see the difference more clearly if we move the smaller triangle so that it lies within the larger triangle (see Figure 3)

Fill rules
Jan Jan Jan Jan Jan Jan Jan date
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call