So talented people have figured out how to make xkcd style graphs in Mathematica, in LaTeX, in Python and in R already.
How can one use MATLAB to produce a plot that looks like the one above?
What I have tried
I created wiggly lines, but I couldn't get wiggly axes. The only solution I thought of was to overwrite them with wiggly lines, but I want to be able to change the actual axes. I also could not get the Humor font to work, the code bit used was:
annotation('textbox',[left+left/8 top+0.65*top 0.05525 0.065],...
'String',{'EMBARRASSMENT'},...
'FontSize',24,...
'FontName','Humor',...
'FitBoxToText','off',...
'LineStyle','none');
For the wiggly line, I experimented with adding a small random noise and smoothing:
smooth(0.05*randn(size(x)),10)
But I couldn't make the white background the appears around them when they intersect…
Best Answer
I see two ways to solve this: The first way is to add some jitter to the x/y coordinates of the plot features. This has the advantage that you can easily modify a plot, but you have to draw the axes yourself if you want to have them xkcdyfied (see @Rody Oldenhuis' solution). The second way is to create a non-jittery plot, and use
imtransform
to apply a random distortion to the image. This has the advantage that you can use it with any plot, but you will end up with an image, not an editable plot.I'll show #2 first, and my attempt at #1 below (if you like #1 better, look at Rody's solution!).
This solution relies on two key functions: EXPORT_FIG from the file exchange to get an anti-aliased screenshot, and IMTRANSFORM to get a transformation.
Here's my initial attempt at jittering