我是靠谱客的博主 寂寞毛衣,这篇文章主要介绍matplotlib画图报错——没有字体项目场景:,现在分享给大家,希望可以做个参考。

项目场景:

提示:这里简述项目相关背景:

使用dendrogram画层次聚类树的时候报没有字体错:RuntimeWarning: Glyph 38142 missing from current font.
加入两行代码解决:

plt.rcParams['font.sans-serif'] = ['SimHei']    # 显示中文标签
plt.rcParams['axes.unicode_minus'] = False
# 可视化
from matplotlib import pyplot as plt
plt.figure(figsize=(30, 100))
plt.rcParams['font.sans-serif'] = ['SimHei']    # 显示中文标签
plt.rcParams['axes.unicode_minus'] = False
plt.title('微博文本层次聚类树状图')
plt.xlabel('微博文本')
plt.ylabel('距离')

dendrogram(
    linkage_matrix,	# (n-1)*4的矩阵
    labels=all_texts,	# 所有文章
    leaf_rotation=-90
)
plt.show()
plt.close()

最后

以上就是寂寞毛衣最近收集整理的关于matplotlib画图报错——没有字体项目场景:的全部内容,更多相关matplotlib画图报错——没有字体项目场景内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(108)

评论列表共有 0 条评论

立即
投稿
返回
顶部