So talented people have figured out how to make xkcd style graphs in Mathematica, in LaTe
Rather than re-implementing all the various plotting functions I wanted to create a generic tool that could convert any existing plot to a xkcd style plot.
This approach means that you can create plots and style them using standard MATLAB functions and then when you're done you can then re-render the plot in an xkcd style while preserving the overall style of the plot.
Plot
Bar & Plot
Box & Plot
The function works by iterating over the children of an axes. If the children are of type line
or patch
it distorts them slightly. If the child is of type hggroup
it then iterates on the sub-children of the hggroup
. I have plans to support other plot types, such as image
, but it's not clear what is the best way to distort image to have an xkcd style.
Finally to ensure that the distortions look uniform (that is, short lines aren't distored more than long lines), I measure the line length in pixels and then up sample proportional to its length. I then add noise to every Nth sample which produces lines that have more or less the same amount of distortion.
Rather than pasting several hundred lines of code I'll just link to a gist of the source. Additionally the source code and the code to generate the above examples are freely available GitHub.
As you can see from the examples, it doesn't yet distort the axes themselves although I plan to implement as soon as I figure out the best way to do that.