r/Python • u/domspage • Oct 20 '19
Matplotlib can create plots in the xkcd art style, so you can create plots that look hand drawn.
8
u/jabbalaci Oct 20 '19
What's the name of the font used in this plot?
23
u/domspage Oct 20 '19
In the source code you can find the following:
'font.family': ['xkcd', 'xkcd Script', 'Humor Sans', 'Comic Sans MS'],
There is also a GitHub repository where you can find the font.
-14
Oct 20 '19
That doesn't actually answer the question, though. I think this is Comic Sans.
4
u/kyle1elyk Oct 21 '19
If you don't understand an answer there are always people willing to explain, there's no shame in asking. Font family is what you're looking for; in this case the font is
Humor Sansand if the system can't find that then it will default toComic Sans MS1
Oct 21 '19
I do understand the question, and I understand how fonts work. But the question was specifically what font is used in this plot, not "what fonts does the XKCD mode in matplotlib use?"
144
u/enilkcals Oct 20 '19
The XKCD — Matplotlib 3.1.1 documentation is also a pretty handy reference for doing this.
83
16
55
u/madmendude Oct 20 '19
But...why? Your scientists were so preoccupied with whether or not they could, that they never stopped to think if they should.
68
u/wookiecontrol Oct 20 '19
I use it for drafts that are being passed around. This lets people know it is not ready for someone outside to view
41
u/goldenhawkes Oct 20 '19
If my old PhD supervisors are anything to go by, making it obvious it’s a draft will just lead to comments about how it looks unfinished...
15
u/spinicist Oct 20 '19
After 8 years of being a grumpy a post-doc I have finally come to the conclusion that the helpfulness of comments received scales inversely with the number of years post-tenure a person is.
2
u/cutecoder Ignoring PEP 8 Oct 20 '19
That is called the duck in game programming circles and it is useful for managing upwards.
3
27
u/Mooks79 Oct 20 '19
I like hand drawn graphs to prevent people over-interpreting them. It’s like “here’s the general idea I’m trying to convey - don’t start thinking you can make actual predictions with this”.
I also liked it in a book I read ages ago - I think The Art of the Infinite IIRC - where the authors explain that they’re using hand drawn diagrams to always make it clear that the diagrams could never be more than an approximation to the perfection that mathematics describes.
3
u/JimBoonie69 Oct 21 '19
Same. It's not about if one bar is a 72 or 74. What matters is typically the relationship. In some of my experience this style helps convert messages more
11
u/redwall_hp Oct 20 '19
The root of the spirit behind all of engineering and science is to answer the question of "why" with "because I fucking can!" This is why we have airplanes and computers.
7
u/spinicist Oct 20 '19
No, the spirit is "I wonder what happens if I try doing this?"
It's a subtle but very very important difference.
2
19
Oct 20 '19
Work starts and work ends need to be reversed wtf whos happy to get to work and sad leaving work. you monsters
14
u/maskedman1231 Oct 20 '19
I think it's more like "You're happy until work starts, and you're sad until work ends"
2
2
2
2
u/Chemomechanics Oct 20 '19
I tried it out here just to do something different. I like it for conceptual charts where the numbers don’t matter much.
1
1
Oct 20 '19
Can someone explain what line 17 does in the code? I’ve never seen that syntax before.
SINE_FORMULA = r"$sin(x) = \sum_{n=0}\infty\frac{(-1)n}{(2n+1)!}x{2n+1}$"
3
u/pleasepickme Oct 21 '19
This is LaTeX code. It is great for typesetting documents and math. Matplotlib can understand it. https://www.latex-project.org/
1
1
1
u/Rashaverik Oct 21 '19
Here's the original before the pull request went into Matplotlib back 2013.
https://jakevdp.github.io/blog/2012/10/07/xkcd-style-plots-in-matplotlib/
1
u/robberviet Oct 21 '19
This is gold. Years of working with matplotlib only now that I know about it.
1
1
1
1
1
1
0
-10
Oct 20 '19
With me at 10pm the imaginary unit goes off in an extra dimension as the cycle continues while studing quantum mechanics on Netflix and Youtube.
3
1
67
u/domspage Oct 20 '19 edited Oct 20 '19
If anyone is interested, here the code for the graph.
Edit: changed the font to Humor Sans