In my last post, I analysed mine and Rhea's NYT word games for the last two years. Since the analysis is pretty simple (just summaries and aggregates), the time saved by not having to do more in-depth work can be used to think of more interesting ways to show the data.
To make my digital work more fun to create and enjoy, I love mimicking real-life objects, textures, and analogies. My latest gimmick this time was trying to make the charts look like they were embroidered into cloth. Since I was already feeling very Christmasy and cozy, an embroidery style felt like the good side-quest to set off on. I’m certainly not the first to try this and if I could actually embroider, I might have just done that! I love this memorable Reuters piece, which features graphics styled as cloth patches. Inspired by that, I wanted to push myself to replicate the look as accurately as possible strictly using code.
After many hours, I managed to achieve the look entirely within R and ggplot and heavy use of the ImageMagick library. In this post, I’ll break down the process. It requires some familiarity with CLI tools and code, but that barrier is lower than ever and if you wish you can easily paste this post into an LLM to tailor the code to your specific needs.
Why go through the trouble of coding this when there is Photoshop? There seem to be no shortage of ‘embroidery actions and filters’ available for free. All of these may be good options, and no one method is better than the other, but for me the answer is always reproducibility. If I built this in Photoshop, every time I updated the dataset or caught a typo in my ggplot code, I would have to re-export the image, open it in Photoshop, and manually rerun an action or apply some filter. That is a recipe for frustration and as far as possible, the “art” part of this should be programmatic too. If the data changes, I don’t want to repeat a manual post-processing pipeline 1 I also refuse to use generative AI for anything to do with image generation. Nano Banana Pro can probably do the same thing with a prompt, but I don’t care for that. .
You can think of ImageMagick as “headless Photoshop.” It is a powerful command-line tool that lets you manipulate images using text commands instead of a mouse. By writing a script (or a recipe), we can manipulate an image with blurs, color changes, transforms, crops and much much more. In this case, our image being manipulated is a chart made in ggplot , when that data changes, we just re-run the script.
I won’t go into how to download ImageMagick for your OS, but it is pretty straightforward and searchable.
All commands follow this common structure: magick [input] [actions] [output] . Here are some sample commands:
# Convert from jpg to png magick input.jpg output.png # Resize image to new dimensions magick input.jpg -resize 800x600 output.jpg # Make an image gray magick input.jpg -colorspace gray output.jpg
You get the idea. Take one image, do something to it and then save it as another image. You can even combine operations, like maybe taking an image and blurring it and then applying a ‘posterize’ effect:
magick simpson.jpg -blur 0x4 -posterize 8 cant-see-simpson.jpg
... continue reading