matplotlib设置中文字体的方法

为什么无法显示中文:

     matplotlib默认不支持中文字符,因为默认的英文字体无法显示汉字

查看linux/mac下面支持的字体:

    fc-list  

查看支持的字体

    fc-list :lang=zh 查看支持的中文(冒号前面有空格)

例如:
    my_font = font_manager.FontProperties(fname="/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc")

那么问题来了:如何修改matplotlib的默认字体?      

通过matplotlib.rc可以修改,具体方法参见源码(windows/linux)    

通过matplotlib 下的font_manager可以解决(windows/linux/mac)

猜你喜欢

转载自blog.csdn.net/Action1024/article/details/81358916