Default fonts in Seaborn statistical data visualization in iPython

前端 未结 2 1750
我在风中等你
我在风中等你 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 08:03

    Well, if you want to use Arial, you'll need to install the Microsoft core fonts. If I recall correctly, Arial can't be freely redistributed under the same terms as most OSS, so you'll need to agree to the license agreement and install it yourself.

    However, in more general terms, you just want to tweak the rc parameters. (Which can be done either at runtime through matplotlib.rc/matplotlib.rcParams or through a .matplotlibrc file.)

    For example, seaborn is basically doing this (among other things):

    import matplotlib as mpl
    mpl.rcParams['font.family'] = 'Arial'
    

    The error is because you don't have the Arial font installed anywhere on your system.

    You usually don't want to touch the font manager directly. There are plenty of exceptions, (e.g. using a specific .ttf file) but generally speaking, you'll want to stick to using the fonts installed on your system. You may want to specify a FontProperties instance, but even for that, it's usually easier to specify things through other keyword arguments.

提交回复
热议问题