2017-01-12 66 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並將其複製到相應的目錄中,但它不起作用。 –