examples/showcase/xkcd.py does not show line randomization on Mac OS X #2269

artisan-roaster-scope opened this Issue Aug 1, 2013 · 12 comments


None yet

10 participants


Running the xkcd.py does not show the randomized lines as on the pics shown on the matplotlib homepage. The Comic font, however, is shown. See the images below. This is verified on OS X 10.7.5 and OS X 10.8.? with Python 2.7.5 and Python 3.3.2, matplotlib installed from the just released tar.

# python 
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
>>> quit()
# cd matplotlib-1.3.0/examples/showcase
# python xkcd.py

screen shot 2013-08-01 at 18 05 53
screen shot 2013-08-01 at 18 05 55

mdboom commented Aug 1, 2013

Which backend? Try one of the *Agg backends...


Fixed. I added the following two lines to the top of the file showcase/xkcd.py

import matplotlib

and it worked as expected

Thanks a lot!

screen shot 2013-08-01 at 18 29 20
screen shot 2013-08-01 at 18 29 22


I added the following two lines to the top of the file showcase/xkcd.py:

import matplotlib

I'll add that information to the issue and then you can close it.

Thanks a lot!

On 01.08.2013, at 18:19, Michael Droettboom wrote:

Which backend? Try one of the *Agg backends...

Reply to this email directly or view it on GitHub.

mdboom commented Aug 1, 2013

Thanks. We still may want to document this shortcoming better.


Thanks! This helped me get it working as well. I think that you actually are not using the super-awesome XKCD "humor sans" font (it looks a little more "hand drawn" than what you have on your plots). You need to install it (http://xkcdsucks.blogspot.com/2009/03/xkcdsucks-is-proud-to-present-humor.html) and then delete your ~/.matplotlib/fontList.cache file. Then matplotlib can find the humor sans font.




I went through all the hassle of trying to install PyQT, which requires Qt, which requires SIP, in order to follow the fix here. But then I figured out that any Agg backend will do the trick. TkAgg still allows the use of interactive Python, so I went with that one. So all I add to my code is

import matplotlib

and I don't have to install any other wacky stuff, and it works from a script or iPython. Then I get plots that look nice and wavy!

stared commented Apr 2, 2014

For me removing font cache solved the problem (there was no need to use any other backend), see http://stackoverflow.com/questions/19663986/getting-xkcd-plots-using-matplotlib, so +1 for @DanHickstein .


Thank you @jmason86, your solution worked for me

lanpa commented Jul 16, 2014

I also solved the problem using jmason86's solution.


jmason86's solution saved me much trouble going through all those hassle. Thanks Mason!


With following code my circle is also rendered as regular plots . There should be a bad circle, isn't it ?

patches = []
fig, ax = plt.subplots()
circle = Circle((0.2, 0.12), 0.1)
p = PatchCollection(patches)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment