1. 程式人生 > >seaborn在pycharm中繪圖不出圖原因

seaborn在pycharm中繪圖不出圖原因

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

np.random.seed(sum(map(ord, 'axis_grids')))
tips = sns.load_dataset('tips')
tips.head()

# 將FacetGrid例項化出來
g = sns.FacetGrid(tips, col='time')
g.map(plt.hist, 'tip')

# 散點圖把資料描繪出來 alpha透明程度,越小越透明
g = sns.FacetGrid(tips, col='sex', hue='smoker')
g.map(plt.scatter, 'total_bill', 'tip', alpha=.1)
g.add_legend()
plt.show()

在程式碼最後加上plt.show( )即可。