PlotDevice is a Mac OS X application that lets you write Python scripts to produce 2D graphics. It provides a built-in editor and allows you to view your script’s results as you write it. The graphics that you ‘draw with code’ can be saved as PDFs, images, or even Quicktime/GIF animations.

First Steps

The first thing you’ll want to do once you’ve downloaded the application is run some example scripts. There’s a folder with tons of sample code that can be accessed from the app’s Examples menu. Select one of them and press ⌘R to see it run (if the script is an animation, you can bring it to a halt by pressing ⌘.). Then try changing some numbers in the script and run it again to see what happens:

Next you’ll want to have a look at the reference to see what scripting commands are available and the sorts of parameters they accept. We’ll learn how to interpret the reference’s ‘syntax definitions’ in the chapter on drawing primitives. But in the meantime, skimming over the list of commands should give you a general sense of what’s possible.

PlotDevice commands let you draw primitive shapes (polygons, circles), create your own shapes (Bézier paths), transform the ‘canvas’ (rotate, scale, etc.), and work with content generated elsewhere (images & text).

Learning the Ropes

After you’ve played around with the app for a bit, you should take a look at the other chapters in this Tutorial. They contain essential tips on how the commands work and how to use them in scripts of your own. To really understand what’s going on in your PlotDevice scripts, we recommend reading through at least:

Readers who are new to programming may also find the chapters on datatypes and control structures helpful:

Seasoned Pythonistas (and emacs partisans) will want to take a look at:

PlotDevice is Python

The programming language that underlies PlotDevice is Python (created by Guido van Rossum in the early ’90s). Python emphasizes code readability and programmer productivity; qualities that make it an excellent choice for those just learning to program. These same traits also result in an expressive ‘sketching’ language that makes it easy to experiment in your code without being weighed down by syntactic bookkeeping.

The official documentation is thorough and highly-readable. If you’re just starting out, the Python Tutorial is a well-paced introduction to the language as well as general programming concepts. We like to keep these chapters on the nightstand:

Writing your scripts in Python also means being able to take advantage of the thousands of third-party libraries that have been written by the community. Try searching for a topic of interest at the Python Package Index. We bet you’ll be pleasantly surprised by the amount of code you won’t have to write.