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

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)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。