<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[matplotlib画图不能正确显示中文]]></title><description><![CDATA[<p dir="auto">解决方案</p>
<ol>
<li>
<p dir="auto">下载simhei字体（<a href="https://github.com/zhangsheng377/stats_stock/blob/master/simhei.ttf" rel="nofollow ugc">https://github.com/zhangsheng377/stats_stock/blob/master/simhei.ttf</a>)，存到 /usr/share/fonts 目录下，可新建文件夹。</p>
</li>
<li>
<p dir="auto">然后刷新字体：</p>
</li>
</ol>
<pre><code>sudo fc-cache -f -v
</code></pre>
<p dir="auto">可从回显中检查有无载入刚才的字体文件。</p>
<ol start="3">
<li>然后删除matplotlib字体缓存：</li>
</ol>
<pre><code>rm -rf /home/xxx/.cache/matplotlib
</code></pre>
<blockquote>
<p dir="auto">xxx替换为自己的账号</p>
</blockquote>
<ol start="4">
<li>然后在python中指定字体，即可正常显示中文：</li>
</ol>
<pre><code>import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/1059/matplotlib画图不能正确显示中文</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 09:38:29 GMT</lastBuildDate><atom:link href="http://an.forum.genostack.com/topic/1059.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Mar 2024 08:13:26 GMT</pubDate><ttl>60</ttl></channel></rss>