Default fonts in Seaborn statistical data visualization in iPython

前端 未结 2 1760
我在风中等你
我在风中等你 2021-02-08 07:38

After multiple problems trying to run stanford.edu/~mwaskom/software/seaborn/ in Anaconda and Enthought for Mac (many problems with dependencies and versions), I was able to run

2条回答
  •  面向向阳花
    2021-02-08 07:48

    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 = [f.name for f in font_objects]
    print font_names
    

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

    sns.set(font="Verdana")
    

    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.

提交回复
热议问题