You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
examples/showcase/xkcd.py does not show line randomization on Mac OS X #2269
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__
'1.3.0'
>>> quit()
# cd matplotlib-1.3.0/examples/showcase# python xkcd.py
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
matplotlib.use('TkAgg')
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!
Activity
mdboom commentedon Aug 1, 2013
Which backend? Try one of the *Agg backends...
mdboom commentedon Aug 1, 2013
Thanks. We still may want to document this shortcoming better.
DanHickstein commentedon Sep 4, 2013
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.
ElDeveloper commentedon Dec 16, 2013
👍
starfleetjames commentedon Mar 10, 2014
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
matplotlib.use('TkAgg')
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 commentedon 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 .
gcmartinelli commentedon May 14, 2014
Thank you @jmason86, your solution worked for me
lanpa commentedon Jul 16, 2014
I also solved the problem using jmason86's solution.
xiumingzhang commentedon Nov 8, 2015
jmason86's solution saved me much trouble going through all those hassle. Thanks Mason!
liangz0707 commentedon Nov 30, 2015
With following code my circle is also rendered as regular plots . There should be a bad circle, isn't it ?