That is a pretty thorny one; I just tested it out and it seems that simply running it a couple times in different cells works, as well as if you remove the last elif statement code, and then replace it again (that is, the image then shows up). My best guess is that the image generated is being swallowed somehow at first, but there isn't an obvious place for where I would suspect it would happen. One could analyze this by examining the local folder where the images and code live (often .sage/sage_notebook.sagenb/home/admin/) but as tmonteil says, it's probably not worth the effort to track this down at this point. Thank you nonetheless for the report.