You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Applications are open for the 2018 John Hunter Matplotlib Summer Fellowship. Apply now!
Version 2.2.2.post1722+g3b337c9d6
Fork me on GitHub

Table Of Contents


matplotlib.pyplot.xkcd(scale=1, length=100, randomness=2)[source]

Turn on xkcd sketch-style drawing mode. This will only have effect on things drawn after this function is called.

For best results, the "Humor Sans" font should be installed: it is not included with matplotlib.

scale : float, optional

The amplitude of the wiggle perpendicular to the source line.

length : float, optional

The length of the wiggle along the line.

randomness : float, optional

The scale factor by which the length is shrunken or expanded.


This function works by a number of rcParams, so it will probably override others you have set before.

If you want the effects of this function to be temporary, it can be used as a context manager, for example:

with plt.xkcd():
    # This figure will be in XKCD-style
    fig1 = plt.figure()
    # ...

# This figure will be in regular style
fig2 = plt.figure()

Examples using matplotlib.pyplot.xkcd