Draws a circular chord diagram from a matrix, showing flows between rows and columns using sectors and ribbons. The plot is rendered using base graphics and supports flexible styling via object-based arguments.
Arguments
- x
A numeric matrix. Rows and columns define the connections between sectors.
- sector
sector styling. Can be:
a logical (
TRUE/FALSE) to enable/disable sectors,a vector of colors,
or a list with elements
colandborder.
Colors are recycled to match the number of sectors (
nrow(x) + ncol(x)).- ribbon
ribbon styling. Can be:
a logical (
TRUE/FALSE) to enable/disable ribbons,a vector of colors,
or a list with elements
colandborder.
Colors are recycled to match the number of row categories (
nrow(x)).- labels
label styling. Can be:
a logical (
TRUE/FALSE) to enable/disable labels,a character vector of labels,
or a list with parameters passed to internal label drawing.
- gap
numeric. Gap between sectors in degrees.
- main
character. Main title of the plot.
- ...
additional graphical parameters passed to internal plotting functions.
Value
Invisibly returns a list with label positions:
- x
x-coordinates of labels
- y
y-coordinates of labels
Details
The function constructs a circular layout where:
Columns of
xare placed on one half of the circleRows of
xare placed on the opposite halfRibbon widths are proportional to matrix entries
Sector sizes correspond to marginal sums of the matrix.
Internally, angles are computed in radians and mapped to Cartesian coordinates.
See also
Other plot.special:
plotBinaryTree(),
plotLift(),
plotMiss(),
plotPolar(),
plotPropCI(),
plotTernary(),
plotTimeSeries(),
plotTreemap(),
plotWeb()
Examples
set.seed(1)
x <- matrix(sample(1:10, 36, replace = TRUE), nrow = 6)
rownames(x) <- LETTERS[1:6]
colnames(x) <- LETTERS[1:6]
plotCirc(x)
# Custom colors
plotCirc(
x,
sector = list(col = rainbow(12), border = "grey50"),
ribbon = list(col = rainbow(6), border = NA)
)
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
#> Warning: supplied color is neither numeric nor character
# Custom labels
plotCirc(
x,
labels = list(cex = 0.8, col = "blue", las = 2)
)
