R: Draw a Circle

grid.circle {grid} | R Documentation

## Draw a Circle

### Description

Functions to create and draw a circle.

### Usage

    grid.circle(x=0.5, y=0.5, r=0.5, default.units="npc", name=NULL,
                gp=gpar(), draw=TRUE, vp=NULL)
    circleGrob(x=0.5, y=0.5, r=0.5, default.units="npc", name=NULL,
                gp=gpar(), vp=NULL)

### Arguments

`x` | A numeric vector or unit object specifying x-locations.
`y` | A numeric vector or unit object specifying y-locations.
`r` | A numeric vector or unit object specifying radii.
`default.units` | A string indicating the default units to use if `x`, `y`, `width`, or `height` are only given as numeric vectors.
`name` | A character identifier.
`gp` | An object of class `gpar`, typically the output from a call to the function `gpar`. This is basically a list of graphical parameter settings.
`draw` | A logical value indicating whether graphics output should be produced.
`vp` | A Grid viewport object (or NULL).

### Details

Both functions create a circle grob (a graphical object describing a circle), but only `grid.circle()` draws the circle (and then only if `draw` is `TRUE`).

The radius may be given in any units; if the units are relative (e.g., `"npc"` or `"native"`) then the radius will be different depending on whether it is interpreted as a width or as a height. In such cases, the smaller of these two values will be the result. To see the effect, type `grid.circle()` and adjust the size of the window.

What happens for very small radii is device-dependent: the circle may become invisible or be shown at a fixed minimum size. As from R 2.15.0, circles of zero radius will not be plotted.

### Value

A circle grob. `grid.circle()` returns the value invisibly.

### Warning

Negative values for the radius are silently converted to their absolute value.

### Author(s)

Paul Murrell

### See Also

Grid, `viewport`

[Package grid version 3.1.2 Index]