admin 管理员组

文章数量: 1184232

双子图共享Y轴: 

import matplotlib.pyplot as plt
import numpy as np


# First create some toy data:
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)

# Create two subplots and unpack the output array immediately
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing Y axis')
ax2.scatter(x, y)

多子图共享X轴:

# Share a X axis with each column of subplots
plt.subplots(2, 2, sharex='col')

 多子图共享Y轴:

# Share a Y axis with each row of subplots
plt.subplots(2, 2, sharey='row')

多子图共享X-Y轴:

# Share both X and Y axes with all subplots
plt.subplots(2, 2, sharex='all', sharey='all')

 或者:

# Note that this is the same as
plt.subplots(2, 2, sharex=True, sharey=True)

本文标签: 坐标轴 多子 python