mirror of
https://github.com/Estom/notes.git
synced 2026-04-13 12:19:52 +08:00
matplotlib & pandas
This commit is contained in:
38
Python/matplotlab/gallery/axes_grid1/simple_axes_divider2.md
Normal file
38
Python/matplotlab/gallery/axes_grid1/simple_axes_divider2.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# 简单轴分割器示例2
|
||||
|
||||

|
||||
|
||||
```python
|
||||
import mpl_toolkits.axes_grid1.axes_size as Size
|
||||
from mpl_toolkits.axes_grid1 import Divider
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
fig1 = plt.figure(1, (5.5, 4.))
|
||||
|
||||
# the rect parameter will be ignore as we will set axes_locator
|
||||
rect = (0.1, 0.1, 0.8, 0.8)
|
||||
ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]
|
||||
|
||||
horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.),
|
||||
Size.Scaled(.5)]
|
||||
|
||||
vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)]
|
||||
|
||||
# divide the axes rectangle into grid whose size is specified by horiz * vert
|
||||
divider = Divider(fig1, rect, horiz, vert, aspect=False)
|
||||
|
||||
ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0))
|
||||
ax[1].set_axes_locator(divider.new_locator(nx=0, ny=2))
|
||||
ax[2].set_axes_locator(divider.new_locator(nx=2, ny=2))
|
||||
ax[3].set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0))
|
||||
|
||||
for ax1 in ax:
|
||||
ax1.tick_params(labelbottom=False, labelleft=False)
|
||||
|
||||
plt.show()
|
||||
```
|
||||
|
||||
## 下载这个示例
|
||||
|
||||
- [下载python源码: simple_axes_divider2.py](https://matplotlib.org/_downloads/simple_axes_divider2.py)
|
||||
- [下载Jupyter notebook: simple_axes_divider2.ipynb](https://matplotlib.org/_downloads/simple_axes_divider2.ipynb)
|
||||
Reference in New Issue
Block a user