技术栈

wordcloud在mac上显示中文乱码

bitcarmanlee2023-11-14 20:20

在mac上使用wordcloud显示词云的时候,发现图片中的中文显示乱码。

经过查阅资料发现,wordcloud默认不支持中文,需要指定font参数才能正常显示中文。

对于macos来说,字体可以在如下路径:
/System/Library/Fonts

将代码修改如下:

复制代码
    wc = wordcloud.WordCloud(font_path="/System/Library/fonts/PingFang.ttc",
                             width=1000,
                             height=700,
                             background_color='white',
                             max_words=100, stopwords=stopwords)

生成的词云图片即可正常显示中文。

上一篇:bulldog靶机复现
下一篇:spring boot集成mybatis
相关推荐
pe7er
12 小时前
macOS 应用无法打开(权限问题)解决方案
macos·mac
harmful_sheep
3 天前
mac生效的终端查看
macos
iOS门童
4 天前
macOS 应用"已损坏"无法打开?一文搞懂 Gatekeeper 与解决方案
macos
NPE~
4 天前
[工具分享]Maccy —— 优雅的 macOS 剪贴板历史管理工具
macos·教程·工具·实用工具
差不多程序员
4 天前
Mac安装OpenClaw-cn保姆级教程
macos
dzl84394
4 天前
mac 安装python
开发语言·python·macos
Bruce_Liuxiaowei
4 天前
在 macOS 上通过 Docker 本地安装 OpenClaw 完整教程
macos·docker·容器·openclaw
阿捏利
4 天前
详解Mach-O(十五)Mach-O __DATA_CONST
macos·ios·c/c++·mach-o
ShikiSuen
4 天前
macOS 的 CpLk 中英切换卡顿的元凶在 InputMethodKit 本身
macos
xiayutian_c
4 天前
如虎添翼-MacOS
macos
热门推荐
01GitHub 镜像站点02【OpenClaw 本地实战 Ep.3】突破瓶颈:强制修改 openclaw.json 解锁 32k 上下文记忆03OpenClaw 使用和管理 MCP 完全指南04Clawdbot部署教程:解决‘gateway token missing’授权问题的完整步骤05OpenClaw + 飞书(Feishu)环境搭建指南06Window 10部署openclaw报错node.exe : npm error code 12807Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services08OpenClaw优化飞书API 额度已耗尽问题09AI 规范驱动开发“三剑客”深度对比:Spec-Kit、Kiro 与 OpenSpec 实战指南10AI Agent 平台横评:ZeroClaw vs OpenClaw vs Nanobot