5 ms·
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.
by catacombs 9y ago
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.
- mircealex 9y agoSimply 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.
- wodenokoto 9y agoI'd love to see those 10 lines!
- minimaxir 9y agoI have a R/ggplot2 data visualization tutorial which gets a similar style in about 10 lines: http://minimaxir.com/2017/08/ggplot2-web/ http://minimaxir.com/2017/08/ggplot2-web/
- mircealex 9y agoYou'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.
- minimaxir 9y agoThe key word is "similar." (and yes I do add a titles/subtitle bar/caption)
- mircealex 9y agoApologies, I only examined the first couple of graphs after the first "FiveThirtyEight" keyword, for which you don't have titles, subtitles etc. The graphs on your article look really nice, but they are quite far from resembling FTE's, IMO.
- deleted 9y ago[deleted]
- alanbernstein 9y agoBecause configuring plot styles is significantly less work than switching your entire development environment?
- minimaxir 9y agoR doesn't include a 538 theme, even though ggplot2's theme_minimal() is close.
- catacombs 9y agoYou are correct. There are third-party plugins, like this one: https://github.com/jrnold/ggthemes https://github.com/jrnold/ggthemes, that uses 538's theme.