Recently, I wanted to create a map similar to James Cheshire’s crime map of London,
which shows the most common crimes commited in a rectangular grid of points laid
over London. Instead of using a rectangular grid, I wanted to use hexbins, but
it turns out that ggplot
needs a bit of prodding to do anything other than
simply count the number of observations in each bin.
At the time I couldn’t find a good tutorial on writing custom hexbin functions,
so this post is a reasonably thorough explanation of what I’ve made work.
Continue Reading →
Recently, I came across the Proselint project, which
aspires to be something like a “linter” for written English prose. It differs
from spelling or grammar checker in that it is primarily focused on logic and
style, taking its advice from the work of many prominent writers on writing.
The project seems to be a little rough around the edges (code blocks seem to
make it struggle, for example), but it’s also perfectly usable in its current
form. It’s available as a Python package, so you can pip install proselint
to
get the command-line tool, proselint
.
Thanks to the Flycheck framework it’s comically easy
to get this imported into a Emacs writing environment. The following snippet
will get you up and running in text and markdown modes:
(flycheck-define-checker proselint
"A linter for prose."
:command ("proselint" source-inplace)
:error-patterns
((warning line-start (file-name) ":" line ":" column ": "
(id (one-or-more (not (any " "))))
(message) line-end))
:modes (text-mode markdown-mode gfm-mode))
(add-to-list 'flycheck-checkers 'proselint)
Continue Reading →
I thought I’d jump on the Rust blogging bandwagon. Specifically, I’ve been
toying with a new library to define and
iterate over L-systems in a unique and Rust-inspired fashion. It’s been very
rewarding to fool around with a type system so foreign to my roots in duck- and
weakly-typed languages.
If you haven’t heard of L-systems before,
they’re mostly used to make pretty pictures.
I was able to create a little animation of the first seven iterations of an
L-system that draws Penrose tiles (below).
![Penrose Tile L-system](/images/penrose.gif)
L-systems have put them to a variety of different uses, including modelling
plants and trees,
buildings and cities,
and all manner of interesting
geometric constructions.
They hold their fascination in part because of the way in which a very small
number of basic components and rules can evolve in startling ways over time.
In other words, L-systems put
emergence on display.
Continue Reading →
As the venerable xkcd comic points out, unadjusted
geographic data often ends up looking like a population map. Normally, this
makes it kind of boring, since it doesn’t tell you anything new.
Except, of course, when a visualizing the population is exactly what you had in
mind. I discovered recently that the Australian government keeps track of every
public toilet in the country, for example — and what better way is there
to learn about Australian geography than through such an important public
utility?
![Australia, In Public Toilets](/images/australia-in-public-toilets.png)
As usual, the remainder of this post is a technical discussion of how I created
the graphic above. It was a neat opportunity to make use of hexbinning, and I’m
quite fond of the end result. I haven’t yet figured out a way to add a “shadow”
made of hexagons to indicate the overall shape of Australia, though I would
like to. The fully reproducible code can be found
in my visualization repository on Github.
Continue Reading →
Continuing with the theme of my last post, I wanted to put an interesting
visualization together using some publically available data. The result is the
following (somewhat surprising) graphic:
![health-spending-infovis](/images/spending-spie-final.png)
One of the looming issues in Canadian public policy is how to address the fact
that our population is ageing, and that this will mean a larger burden on many
of the social services that are more heavily consumed by those who are older.
But just how uneven is the consumption of health services? The above should
give you some idea of why this is viewed as a looming problem.
The remainder of this post is a technical discussion of how I created the
visualization. I’m not quite satisfied with the overall approach (I think it
takes quite a while before you can really read the graphic), but it does
serve as a good technical demonstration of what can be accomplished in R.
Continue Reading →