> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/python/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/python/chapter-2courses/21python-for-data-science-and-machine-learning-bootcamp/217python-for-data-visualization-seaborn/2175grids.md).

# 2.1.7.5.Grids

## 0. Grids的繪圖種類

* sns.PairGrid
* sns.FacetGrid

## 1. 使用library

```
import seaborn as sns
```

* 將圖表直接嵌入到Notebook之中

```
%matplotlib inline
```

* 讀入資料

```
tips = sns.load_dataset('tips')
tips.head()
```

![](https://github.com/jenhsuan/python/tree/8fc9c0b8df4ccd709d3078c2d8842af0932de09d/assets/螢幕快照%202018-05-19%20上午9.13.50.png)

```
iris=sns.load_dataset('iris')
iris.head()
```

![](https://github.com/jenhsuan/python/tree/8fc9c0b8df4ccd709d3078c2d8842af0932de09d/assets/螢幕快照%202018-05-20%20上午8.19.00.png)

## 2.PairGrid

```
import matplotlib.pyplot as plt
g = sns.PairGrid(iris)
g.map_diag(sns.distplot)
g.map_upper(plt.scatter)
g.map_lower(sns.kdeplot)
```

![](https://github.com/jenhsuan/python/tree/8fc9c0b8df4ccd709d3078c2d8842af0932de09d/assets/螢幕快照%202018-05-20%20上午8.21.32.png)

## 3.FacetGrid

```
g = sns.FacetGrid(data=tips, col='time',row='smoker')
g.map(sns.distplot,'total_bill')
```

![](https://github.com/jenhsuan/python/tree/8fc9c0b8df4ccd709d3078c2d8842af0932de09d/assets/螢幕快照%202018-05-20%20上午8.22.46.png)
