Graphics and code for chapter 9