2

There is an excellent post on Mathematica here on how to make plots and graphs more cartoony and warm to an audience.

I was wondering if anyone knows of similar ways we can do this in either MATLAB, or possibly python. Is something like this possible? (It is also known as xkcd-style plots)

Community
  • 1
  • 1
Spacey
  • 2,941
  • 10
  • 47
  • 63

1 Answers1

3

Yes there is (in Python at least)!

here's a simple example (basically ripped from a pyplot tutorial):

import numpy as np
import matplotlib.pyplot as plt

# evenly sampled time at 200ms intervals
t = np.arange(0., 5., 0.2)

plt.xkcd(scale=1, length=100, randomness=2)

plt.plot(t, t, 'r', t, t**2, 'b', t, t**3, 'g')
plt.show()

just make sure you have a recent enough version of matplotlib and you should be good to go

here's the docs on the xkcd function - http://matplotlib.org/api/pyplot_api.html?highlight=xkcd#matplotlib.pyplot.xkcd

when I run the code above on my computer I see:

enter image description here

Brad
  • 1,367
  • 1
  • 8
  • 17
  • Wow! I think you have finally convinced me to take up Python! :-) – Spacey Feb 05 '14 at 14:15
  • Can you actually make those same type of plots/figures you see in the mathematica post? – Spacey Feb 05 '14 at 14:15
  • http://matplotlib.org/xkcd/gallery.html. This is a bunch of xkcd type plots made in matplotlib. I didn't see the exact one that was from the post, but yes, I am certain that you could make it. – cc7768 Feb 05 '14 at 14:19
  • I don't see why not. It's just a different series to define the curve (adjust the numpy array) and then adding comments. Comments can be added thusly: http://matplotlib.org/users/text_intro.html (per the link I embedded you may need to get a different font though to really make it look good) – Brad Feb 05 '14 at 14:20