Live data from Hacker News

How to Generate FiveThirtyEight Graphs in Python

dataquest.io

31–40 of 56 posts

Re: How to Generate FiveThirtyEight Graphs in Python

#31
It's worth nothing as an interesting background note that FiveThirtyEight uses ggplot2/R for their data visualization workflows instead of matplotlib/Python. Specifically, they export ggplot2 visualizations as a PDF/SVG vector image which then can be precisely annotated in Illustrator.

More info in this video: https://channel9.msdn.com/Events/useR-international-R-User-c...

Re: How to Generate FiveThirtyEight Graphs in Python

#33

Why go through all this trouble? You can accomplish the same plot in less than 10 lines of code in R, which includes a 538 theme.

I'd love to see those 10 lines!

I have a R/ggplot2 data visualization tutorial which gets a similar style in about 10 lines: http://minimaxir.com/2017/08/ggplot2-web/

Re: How to Generate FiveThirtyEight Graphs in Python

#34

Or learn JavaScript and just use D3. It does this out of the box given the dataset.

D3 looks really nice, but half the time I try to use it for something that doesn't closely match a Bostock example, I end up giving up and just coding it myself with SVG primitives. I don't understand the motivation behind D3's complex API.

D3 is a functional paradigm for graphics. From the D3 intro: "...styles, attributes, and other properties can be specified as functions of data in D3, not just simple constants."

This sounds trite, but it's enormously powerful and it's what makes D3 worth learning.

Re: How to Generate FiveThirtyEight Graphs in Python

#35
post #14
post #7

Earlier quoted context omitted.

I agree – it's interesting how one is initially drawn to, yet eventually tires of these sorts of plot styles. While Seaborn strikes a good balance, clear and simple monochrome plots never go out of fashion. This is just as much the case when building fancy interactive plots using Shiny/Plotly etc.

Interesting, @bede @v3gas I would love to hear your thoughts on my plots -- http://abhirag.in/articles/price_data_present.html Too fancy? Too plain? Kinda ok? Kinda new to matplotlib, so your feedback would help :)

Nice charts.

Just one idea, on your vegetable chart, you have onions as a red line and tomatoes as yellow. I would swap them around, as I automatically associate tomatoes with red.

Re: How to Generate FiveThirtyEight Graphs in Python

#37

Earlier quoted context omitted.

I'd love to see those 10 lines!

I have a R/ggplot2 data visualization tutorial which gets a similar style in about 10 lines: http://minimaxir.com/2017/08/ggplot2-web/

You're not adding a title, a subtitle, a signature bar. You're not bolding the line at y = 0, you're using block-style legends instead of adding customized labels. All these will require extra code.

Your example is potentially misleading in this discussion for anyone who won't bother to go through that article you linked to.

I'm not saying you can't do the graphs in under 10 lines of code, I'm just saying that your example totally misses the point.

Re: How to Generate FiveThirtyEight Graphs in Python

#38

Why go through all this trouble? You can accomplish the same plot in less than 10 lines of code in R, which includes a 538 theme.

R doesn't include a 538 theme, even though ggplot2's theme_minimal() is close.

You are correct. There are third-party plugins, like this one: https://github.com/jrnold/ggthemes, that uses 538's theme.

Re: How to Generate FiveThirtyEight Graphs in Python

#39

Earlier quoted context omitted.

I have a R/ggplot2 data visualization tutorial which gets a similar style in about 10 lines: http://minimaxir.com/2017/08/ggplot2-web/

You're not adding a title, a subtitle, a signature bar. You're not bolding the line at y = 0, you're using block-style legends instead of adding customized labels. All these will require extra code. Your example is potentially misleading in this discussion for anyone who won't bother to go through that article you linked to. I'm not saying you can't do the graphs in under 10 lines of code, I'm just saying that your e…

The key word is "similar." (and yes I do add a titles/subtitle bar/caption)

Re: How to Generate FiveThirtyEight Graphs in Python

#40

Earlier quoted context omitted.

It really depends on why you're generating the graphs for. If you needed a visualization for a storytelling article, I really doubt you'd prefer matplotlib's bland standard style. If you just want to visualize some data fast for yourself, then, yeah, the standard style is really great - it's readable and saves you time.

> I really doubt you'd prefer matplotlib's bland standard style (MBSS) To be fair, MBSS got much better in the recent version 2.x Before (version 1.x), I always had to use seaborn and/or modify parameters, but now the default style is good enough for most of my use cases.

Yes, I agree! 1.x was pretty ugly
Post reply on HN