[Update: I've made a website for this: http://www.plannedpooling.com/.]
This was a birthday present for my spouse. (Don't worry--I also covered a lot of things -- fruit/nuts/cocoa puffs/etc -- in chocolate. But I think both were appreciated!)
Sometimes people knit with with yarn that has a repeating sequence of colors -- for example, purple, then yellow, then green -- in a more-or-less regular repeating pattern. Most frequently, the colors in the finished product combine without making much of a distinguishable pattern (somewhat like the picture in the lower right, below). But sometimes stitches of the same color group together (as in the upper right picture), and sometimes other patterns emerge.
Inspired by someone at www.ravelry.com who seems to have done the same thing in SAS, I've written some R code that tries to predict what sort of pattern will emerge in the finishes product based on the repeating pattern of colors in the yarn (how many stitches of each color?), the width (in stitches) of the square, and whether your knitting is "flat" (back and forth -- starts next row where last one finished) or "circular" (starts the next row where the last one started).
Here's the function call that generated these plots:
repeats = c(17,5,17,5),
colors = c("#AC00FF",rgb(.71,.5,.9),"green","gold"),
widths = c(46,52,62,82),
type = "flat",
Here's the code that defines this function, which also has an example function call with much more commenting to explain each of the inputs.
I've added functions for use in RStudio that adds a slider controlling the width:
I hope knitters may find this useful, or others may find it fun to play with. (Especially people who might want to play with any number theory that might be involved here?)
If you're new to R, you just have to download R and run the code up through the function call above (well, really just the code defining the two functions used), and then play with it yourself.