subplots绘制子图以及坐标轴大小控制

data = pd.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8]]).T

"""如何绘制子图"""
fig, axes = plt.subplots(2,1)

for ax in axes:
    ax.set_ylabel("y", fontsize=5)
    ax.set_xlabel("x", fontsize=5)
    ax.tick_params(labelsize=5)

axes[0].plot(data[0],data[1])
axes[1].scatter(data[1], data[0], s=20, color="red")

fig, axes = plt.subplots(2,2)

for axs in axes:
    for ax in axs:
        ax.set_ylabel("y", fontsize=5)
        ax.set_xlabel("x", fontsize=5)
        ax.tick_params(labelsize=5)

axes[0][0].plot(data[0],data[1])
axes[0][1].scatter(data[1], data[0], s=20, color="red")

plt.show()

 

 

https://blog.csdn.net/htuhxf/article/details/82986440?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase

你可能感兴趣的:(数据分析)