xkcd style graphs in MATLAB

前端 未结 4 639
孤独总比滥情好
孤独总比滥情好 2020-12-04 04:29

\"xkcd-style

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

4条回答
  •  有刺的猬
    2020-12-04 05:04

    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.

    Examples

    Plot Enter image description here

    Bar & Plot

    Enter image description here

    Box & Plot Enter image description here

    How it works

    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.

    The Code

    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.

提交回复
热议问题