Search This Blog

packcircles version 0.2.0 released

Version 0.2.0 of the packcircles package has just been published on CRAN. This package provides functions to find non-overlapping arrangements of circles in bounded and unbounded areas.

The package how has a new circleProgressiveLayout function. It uses an efficient deterministic algorithm to arrange circles by consecutively placing each one externally tangent to two previously placed circles while avoiding overlaps. It was adapted from a version written in C by Peter Menzel who lent his support to creating this R/Rcpp version.

The underlying algorithm is 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 (Available from ACM).

Here is a small example of the new function, taken from the package vignette:

library(packcircles)
library(ggplot2)
t

The package vignette for the new function has more examples including how to use ggplot2 and ggiraph to create an SVG image of a circle layout with pre-defined colours and dynamic labelling.

For those who prefer simpler things, the package can also be used quite successfully with base graphics.

Note for existing users

This new version has also seen a general tidy up of the existing functions in an attempt to make things consistent across the package. In particular:

circleLayout has been replaced by a new function circleRepelLayout. The new function accepts circles sizes as either areas or radii, with the default being area, unlike circleLayout which assumed sizes were radii. The type of size value can be specified using the sizetype argument.

circlePlotData has been replaced by a new function circleLayoutVertices. The new function has a sizetype argument to specify whether the input circle sizes are areas or radii. By default, radius is assumed as this matches the output of the layout functions (I'll wait to hear if this causes any confusion).

In both cases the original function has been retained for backwards compatibility but is deprecated and will be removed in a future release.

Get link

Facebook

Twitter

Pinterest

Google+

Email

Other Apps

Labels

Comments

Post a Comment

Popular posts from this blog

I've been working on a small Java application with a colleague to simulate animal movements and look at the efficiency of different survey methods. It uses the GeoTools library to support map projections and shapefile output. GeoTools is great but comes at a cost in terms of size: the jar for our little application alone is less than 50kb but bundling it with GeoTools and its dependencies blows that out to 20Mb.

The application code has been changing on a daily basis as we explore ideas, add features and fix bugs. Working with my colleague at a distance, over a fairly feeble internet connection, I wanted to package the static libraries and the volatile application into separate jars so that he only needed to download the former once (another option would have been for my colleague to set up a local Maven repository but for various reasons this was impractical).

A slight complication with bundling GeoTools modules into a single jar (aka uber-jar) is that individual modules make ext…

Some time ago I wrote an R function to fit an ellipse to point data, using an algorithm developed by Radim Halíř and Jan Flusser1 in Matlab, and posted it to the r-help list. The implementation was a bit hacky, returning odd results for some data.
A couple of days ago, an email arrived from John Minter asking for a pointer to the original code. I replied with a link and mentioned that I'd be interested to know if John made any improvements to the code. About ten minutes later, John emailed again with a much improved version ! Not only is it more reliable, but also more efficient. So with many thanks to John, here is the improved code:
fit.ellipse <- function (x, y = NULL) {
# from:
# http://r.789695.n4.nabble.com/Fitting-a-half-ellipse-curve-tp2719037p2720560.html
#
# Least squares fitting of an ellipse to point data
# using the algorithm described in:
# Radim Halir & Jan Flusser. 1998.
# Numerically stable direct least squares fitting of ellipses.
…

Me

I'm really an ecologist but pretend to be a programmer and a statistician. Most of my work has involved ecological research and conservation in Australia, with some forays into fire ecology and vegetation mapping.
Very occasionally I go outside and look at real plants and animals, especially Banksias and blue-banded bees.