美文网首页
python 作图中文标签乱码解决方案

python 作图中文标签乱码解决方案

作者: 飘舞的鼻涕 | 来源:发表于2020-09-03 14:32 被阅读0次
    Figure_1.png

    有任何建议或疑问,请加 Q群: 798192515 ,共同探讨学习
    如R/python代码编程作图等方面需要帮忙,欢迎来店咨询 之恒科技, 挥动热情的小爪爪期待你哦

    中文无法显示

    --- way1

    from matplotlib import pyplot as plt
    plt.rc("font", family = "MicroSoft YaHei")
    

    --- way2

    from matplotlib import font_manager
    my_font = font_manager.FontProperties(fname=r"C:\Windows\Fonts\msyh.ttc")
    plt.xticks(indx,['ath1','ath2','aathk3','a4th','a5th'],FontProperties = my_font)
    

    标签值太长 无法完整显示

    调整字体大小 和 字体显示方向 即可

    from matplotlib import font_manager
    my_font = font_manager.FontProperties(fname=r"C:\Windows\Fonts\msyh.ttc")
    plt.xticks(indx,['ath1','ath2','aathk3','a4th','a5th'],FontProperties = my_font,fontsize = 8,rotation= 60)
    

    相关文章

      网友评论

          本文标题:python 作图中文标签乱码解决方案

          本文链接:https://www.haomeiwen.com/subject/mdansktx.html