Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8625069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:41:26+00:00 2026-06-12T07:41:26+00:00

So talented people have figured out how to make xkcd style graphs in Mathematica

  • 0

xkcd-style graph

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:41:28+00:00Added an answer on June 12, 2026 at 7:41 am

    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!).

    enter image description here

    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.

    %# define plot data
    x = 1:0.1:10;
    y1 = sin(x).*exp(-x/3) + 3;
    y2 = 3*exp(-(x-7).^2/2) + 1;
    
    %# plot
    fh = figure('color','w');
    hold on
    plot(x,y1,'b','lineWidth',3);
    plot(x,y2,'w','lineWidth',7);
    plot(x,y2,'r','lineWidth',3);
    
    xlim([0.95 10])
    ylim([0 5])
    set(gca,'fontName','Comic Sans MS','fontSize',18,'lineWidth',3,'box','off')
    
    %# add an annotation 
     annotation(fh,'textarrow',[0.4 0.55],[0.8 0.65],...
         'string',sprintf('text%shere',char(10)),'headStyle','none','lineWidth',1.5,...
         'fontName','Comic Sans MS','fontSize',14,'verticalAlignment','middle','horizontalAlignment','left')
    
    %# capture with export_fig
    im = export_fig('-nocrop',fh);
    
    %# add a bit of border to avoid black edges
    im = padarray(im,[15 15 0],255);
    
    %# make distortion grid
    sfc = size(im);
    [yy,xx]=ndgrid(1:7:sfc(1),1:7:sfc(2));
    pts = [xx(:),yy(:)];
    tf = cp2tform(pts+randn(size(pts)),pts,'lwm',12);
    w = warning;
    warning off images:inv_lwm:cannotEvaluateTransfAtSomeOutputLocations
    imt = imtransform(im,tf);
    warning(w)
    
    %# remove padding
    imt = imt(16:end-15,16:end-15,:);
    
    figure('color','w')
    imshow(imt)
    

    Here’s my initial attempt at jittering

    enter image description here

    %# define plot data
    x = 1:0.1:10;
    y1 = sin(x).*exp(-x/3) + 3;
    y2 = 3*exp(-(x-7).^2/2) + 1;
    
    %# jitter
    x = x+randn(size(x))*0.01;
    y1 = y1+randn(size(x))*0.01;
    y2 = y2+randn(size(x))*0.01;
    
    %# plot
    figure('color','w')
    hold on
    plot(x,y1,'b','lineWidth',3);
    plot(x,y2,'w','lineWidth',7);
    plot(x,y2,'r','lineWidth',3);
    
    xlim([0.95 10])
    ylim([0 5])
    set(gca,'fontName','Comic Sans MS','fontSize',18,'lineWidth',3,'box','off')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If the user opens two forms of the same kind, one will have a
I am working on a project for one small school organization, for talented sportists,
my robotics lab is looking for programmers to work on some projects we have
I have been stuck on this all weekend and failed miserably! Please help me
I am getting some HTML from server and showing in Textview. The HTML have
I'm thinking about moving one of my projects onto Windows Azure - But was
Recently in my project I have came across the image in the link .
Hi friends hope all r doing well. I have a problem while reading xml
I'm posting this as a vent for my questions (I will have a multitude).
My question is: why do primitive types have to be wrapped in an object,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.