Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Piet Mondrian Composition with Red, Blue, Black, Yellow, and Gray (1921):

An example draw from my simulation function:

We're in the midst of planning our spring course on Empirical Research Methods, and as a result, I've found myself spending a lot of time thinking about some of the fist ideas in statistics – For example, that the data we observe are actually draws from some (usually unobserved) generating function.

On a recent museum triup, I started thinking about how we could apply this idea to abstract art. Here, I thought, we could think of a particular painting as a single manifestation of some set of generating rules.

Piet Mondrian has a ton of work in a style I thought would be interesting to explore – his work involves combinations of a small number of lines and filled rectangles.

In order to experiment, I decided to write a function which would simulate the (1921) Composition with Red, Blue, Black, Yellow, and Gray (1921) featured above.

My first idea was to maintain the same set lines and colors, while varying (slightly) the locations and widths of those lines – we can think of these locations as parameters drawn from specified distributions. To start, I only use uniform distributions, with means near the values in the original.

For the color, I found a site that extracts hexadecimal colors, which R recognizes.

The result, I think, is interesting. While the variation is still quite constrained, this lets us examine the abstract art.. abstractly (ha!)

Here are a few more draws from the function:

Here is the code for the simulation – (it's a bit of a mess). Feel free to download, experiment with, and improve it!

`sim.func = function() {<br /><br />    # pick a place (near the middle) for central anchor line:<br />    left.anchor = runif(1, 40, 60)<br /><br />    width = runif(1, 2, 3)<br /><br />    right.anchor = left.anchor + width<br /><br />    # plot:<br />    plot(0, 0, type = "n", xlim = c(0, 100), ylim = c(0, 10), xaxt = "n", yaxt = "n", <br />        ann = FALSE)<br /><br />    polygon(c(left.anchor, left.anchor, right.anchor, right.anchor), c(-1, 11, <br />        11, -1), col = "#1c1b23")<br /><br />    upper.left = runif(1, 7, 9)<br />    lower.left = runif(1, 2, 5)<br /><br />    small.line.height = runif(1, 0.1, 0.2)<br /><br />    polygon(c(-100, -100, left.anchor, left.anchor), c(lower.left, lower.left + <br />        small.line.height, lower.left + small.line.height, lower.left), col = "#1c1b23")<br /><br />    polygon(c(-100, -100, left.anchor, left.anchor), c(upper.left, upper.left + <br />        small.line.height, upper.left + small.line.height, upper.left), col = "#1c1b23")<br /><br />    polygon(c(-10, -10, left.anchor, left.anchor), c(upper.left + small.line.height, <br />        12, 12, upper.left + small.line.height), col = "#cbccd4")<br /><br />    polygon(c(-10, -10, left.anchor, left.anchor), c(-1, lower.left, lower.left, <br />        -1), col = "#cbccd4")<br /><br /><br /><br />    upper.right = runif(1, 7, 9)<br /><br />    polygon(c(left.anchor, left.anchor, 200, 200), c(upper.right, upper.right + <br />        small.line.height, upper.right + small.line.height, upper.right), col = "#1c1b23")<br /><br />    polygon(c(left.anchor + width, left.anchor + width, 200, 200), c(upper.right + <br />        small.line.height, 20, 20, upper.right + small.line.height), col = "#db5b2c")<br /><br />    polygon(c(-10, -10, left.anchor, left.anchor), c(lower.left + small.line.height, <br />        upper.left, upper.left, lower.left + small.line.height), col = "#273f70")<br /><br />    lowest.left = runif(1, 0.1, 1.2)<br /><br />    polygon(c(-100, -100, left.anchor, left.anchor), c(lowest.left, lowest.left + <br />        small.line.height, lowest.left + small.line.height, lowest.left), col = "#1c1b23")<br /><br />    lh.ref = runif(1, 5, 20)<br /><br />    polygon(c(lh.ref, lh.ref, lh.ref + width, lh.ref + width), c(lowest.left, <br />        upper.left, upper.left, lowest.left), col = "#1c1b23")<br /><br /><br />    lh.mid = lower.left + runif(1, 0.1, 0.4) * (upper.left - lower.left)<br /><br />    polygon(c(lh.ref, lh.ref, 200, 200), c(lh.mid, lh.mid + small.line.height, <br />        lh.mid + small.line.height, lh.mid), col = "#1c1b23")<br /><br /><br />    lowest.right = runif(1, 0.1, 1.6)<br /><br />    polygon(c(left.anchor + width, left.anchor + width, 105, 105), c(lowest.right, <br />        lowest.right + small.line.height, lowest.right + small.line.height, <br />        lowest.right), col = "#1c1b23")<br /><br />    rh.ref = runif(1, 75, 90)<br /><br />    polygon(c(left.anchor + width, left.anchor + width, rh.ref, rh.ref), c(-1, <br />        lowest.right, lowest.right, -1), col = "#1c1b23")<br /><br />    polygon(c(rh.ref, rh.ref, 200, 200), c(-1, lowest.right, lowest.right, -1), <br />        col = "#dccd1e")<br /><br />    polygon(c(right.anchor, right.anchor, 200, 200), c(lowest.right + small.line.height, <br />        lh.mid, lh.mid, lowest.right + small.line.height), col = colors())<br /><br />    polygon(c(right.anchor, right.anchor, 200, 200), c(lh.mid + small.line.height, <br />        upper.right, upper.right, lh.mid + small.line.height), col = "#cbccd4")<br /><br />    top.left = runif(1, 0.1, 0.3) * (10 - upper.left) + upper.left + small.line.height<br /><br />    polygon(c(-100, -100, left.anchor, left.anchor), c(top.left, top.left + <br />        small.line.height, top.left + small.line.height, top.left), col = "#1c1b23")<br /><br />    polygon(c(-100, -100, left.anchor, left.anchor), c(upper.left + small.line.height, <br />        top.left, top.left, upper.left + small.line.height), col = colors())<br /><br />}<br />`