Live data from Hacker News

How to Generate FiveThirtyEight Graphs in Python

dataquest.io

21–30 of 56 posts

Re: How to Generate FiveThirtyEight Graphs in Python

#21
post #14

Earlier quoted context omitted.

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 :)

The plots are pretty nice. The serif font for the axes captions and the monospaced font for the axis labels are jarring.

Would you prefer I use serif for both or sans serif for both?

Re: How to Generate FiveThirtyEight Graphs in Python

#23

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.

Simply because we're interested to see if we can do in Python whatever we can do in other programming languages / software. We don't really want to learn a new programming language for every thing we can't do in Python yet.

Also, it took 17 lines of code to generate the graph in the tutorial, among which 6 lines were to add labels (excluding from the total the lines of code for reading in the data or importing modules). The teaching approach makes it look that long.

You could also write some functions if you coded this kind of graphs regularly, and make the whole process a breeze.

Re: How to Generate FiveThirtyEight Graphs in Python

#24
For the attribution bar at the bottom of the figure, why not use the text() kwarg xycoords="figure points" or "figure pixels", which both enforces the semantic distinction between the axes (where the data goes) and the figure (where other stuff goes), and avoids having to guess and check the coordinates.

Re: How to Generate FiveThirtyEight Graphs in Python

#27
Interesting article, and very helpful. Over the years whenever I need to generate a graph I'd know I have to play around with axies.

Would be more interesting if someone could actuslly replicate the Irma one. But I figure it probably is a plotting around the datapoint (similar idea like a best fit line, but as a curve).

So my tl;dr for generating any interesting graph is a lot of coding... a lot of playing with attributes and modeling.

Re: How to Generate FiveThirtyEight Graphs in Python

#28
post #5

Pretty cool, but I actually prefer the standard style in matplotlib.

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.

Re: How to Generate FiveThirtyEight Graphs in Python

#29

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.

Because configuring plot styles is significantly less work than switching your entire development environment?

Re: How to Generate FiveThirtyEight Graphs in Python

#30

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.
Post reply on HN