Luis Miguel Luis Miguel - 1 year ago 154
Python Question

Default fonts in Seaborn statistical data visualization in iPython

After multiple problems trying to run in Anaconda and Enthought for Mac (many problems with dependencies and versions), I was able to run it from an Enthought virtual environment in Ubuntu (running on VirtualBox).

Following some of their tutorials I recreated the following:

enter image description here

But it bothers me that the fonts in use are not the ones designed for Seaborn, but the closest one.

Does anybody has experience in tweaking the font selection in matplotlib? Any good tutorial on how to use matplotlib's font manager?

Answer Source

As Joe notes, Arial isn't installed on Ubuntu by default, but it's easy to install. This is what I do for testing on Travis, which is an Ubuntu environment:

sudo apt-get install msttcorefonts -qq

Seaborn also exposes the font option at the top level of the style control, so you could also easily use one that's installed on your system. As far as I can tell from poking around, you can get a list of possible fonts this way:

import matplotlib as mpl
font_paths = mpl.font_manager.findSystemFonts()
font_objects = mpl.font_manager.createFontList(font_paths)
font_names = [ for f in font_objects]
print font_names

Once you've found one you want to use, just set it by doing, e.g.,


Of course this would have to be done at the top of every script/notebook that's going to generate seaborn plots (which is annoying), so improving the use of non-default styles is on the roadmap for 0.3.