circleProgressiveLayout: Progressive layout algorithm

Description Usage Arguments Details Value Examples

View source: R/circleProgressiveLayout.R

Description

Arranges a set of circles, which are denoted by their sizes, by consecutively placing each circle externally tangent to two previously placed circles while avoiding overlaps.

Usage

1
circleProgressiveLayout(x, sizecol = 1, sizetype = c("area", "radius"))

Arguments

x

Either a vector of circle sizes, or a matrix or data frame with one column for circle sizes.

sizecol

The index or name of the column in x for circle sizes. Ignored if x is a vector.

sizetype

The type of size values: either "area" (default) or "radius". May be abbreviated.

Details

Based on an algorithm described in the paper: Visualization of large hierarchical data by circle packing by Weixin Wang, Hui Wang, Guozhong Dai, and Hongan Wang. Published in Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, 2006, pp. 517-520 https://dl.acm.org/citation.cfm?id=1124851

The implementation here was adapted from a version written in C by Peter Menzel: https://github.com/pmenzel/packCircles.

Value

A data frame with columns: x, y, radius. If any of the input size values were non-positive or missing, the corresponding rows of the output data frame will be filled with NAs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
areas <- sample(c(4, 16, 64), 100, rep = TRUE, prob = c(60, 30, 10))
packing <- circleProgressiveLayout(areas)

## Not run: 

# Graph the result with ggplot
dat.gg <- circleLayoutVertices(packing)

ggplot(data = dat.gg, aes(x, y, group = id)) +
  geom_polygon(colour = "black", fill = "grey90") +
  coord_equal() +
  theme_void()


## End(Not run)

packcircles documentation built on Nov. 24, 2017, 9:03 a.m.