r/Python • • Jul 03 '14

Replicate FiveThirtyEight plot styles in Matplotlib

https://www.dataorigami.net/blogs/fivethirtyeight-mpl
6 Upvotes

4 comments sorted by

View all comments

3

u/[deleted] Jul 03 '14 edited Jul 03 '14

This is awesome. Thanks for sharing!

EDIT: A few comments:

  • json.loads imported the file as unicode, which occasionally caused errors. yaml.loads fixed this though!

  • The legend.fancybox = True property isn't working for me. Adding a legend.frameon = False in the JSON file fixed that.

  • Might want to add a leged.loc = 'best' property in the JSON file for better legend placement.

  • Perhaps you could add a font.family = 'Helvetica' property? For folks who don't know how to change it and hence might be stuck with the ugly Bitstream Vera Sans.

Immensely grateful for this, thanks a bunch! :D

1

u/amijustahack Jul 10 '14 edited Jul 10 '14

What is yaml.loads and how do you use it to fix the unicode error?

Can you recommend a different font.family (don't have Helvetica)?

2

u/[deleted] Jul 11 '14

Install PyYAML and import yaml to use yaml.loads. It is a function that loads certain objects (including most kinds of json files) as a python dict. Unlike json.loads (which can import data as unicode), yaml.loads would import data as a string. Side note: If you're using python3, json.loads should work just fine.

Roboto is a great free substitute for Helvetica.

1

u/autowikibot Jul 11 '14

Roboto:


Roboto is a sans-serif typeface family introduced with Android Ice Cream Sandwich operating system.

Google describes the font as "modern, yet approachable" and "emotional". The font is licensed under the Apache license. The entire font family was officially made available for free download on January 12, 2012 on the newly launched Android Design website. The family includes regular and oblique styles of Thin, Light, Regular, Medium, Bold, Black, and Condensed widths.

====

Image from article i


Interesting: Mr. ^Roboto | Mr. Roboto ^Project | List of Masters of the Universe ^characters

Parent commenter can toggle ^NSFW or ^delete. Will also delete on comment score of -1 or less. | FAQs | ^Mods | Magic ^Words