2017-01-12 68 views
0

这里是我的样本数据cities_counter[:10]Seaborn,Matplotlib,情节中国误差

[('上海', 285), ('杭州', 225), ('北京', 163), ('广州', 136), ('南京', 130), ('武汉', 124), ('深圳', 88), ('温州', 67), ('苏州', 66), ('宁波', 45)] 

,我想和Seaborn和Matplotlib柱状图,所以这里是我的代码

>>> sns.set(style="whitegrid") 
>>> sns.set_color_codes("pastel") 
>>> sns.barplot(x=[k for k, _ in cities_counter[:10]], y=[v for _, v in cities_counter[:10]]) 

和结果是

enter image description here

ENV:

  • 的Windows 10
  • 的Python 3.5

我如何绘制中国人物?

+0

是[这个问题](https://stackoverflow.com/questions/40580584)有帮助吗? –

回答

1

尝试设置matplotlib字体,然后设置seaborn.And确保字体在系统中可用。

它适用于我。

import matplotlib as mpl 
mpl.rcParams['font.sans-serif'] = ['SimHei'] 
mpl.rcParams['font.serif'] = ['SimHei'] 
import seaborn as sns 
sns.set_style("darkgrid",{"font.sans-serif":['simhei', 'Arial']}) 

查看更多有关seaborn.setseaborn.set_style

你也可以看看这个issue

希望这会有所帮助。

+0

嗨,谢谢,我已经下载了SimHei.ttf并将其复制到相应的目录中,但它不起作用。 –