【发布时间】:2021-12-28 09:55:43
【问题描述】:
基于this 使用 python 在 matplotlib 上的多个子图的文章,例如以 2x2 矩阵的形式创建子图非常容易。使用示例 4 中的代码,我可以获得以下形式的支持: 带代码:
import matplotlib.pyplot as plt
import numpy as np
fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(x, y)
axs[0, 0].set_title('Axis [0, 0]')
axs[0, 1].plot(x, y, 'tab:orange')
axs[0, 1].set_title('Axis [0, 1]')
axs[1, 0].plot(x, -y, 'tab:green')
axs[1, 0].set_title('Axis [1, 0]')
axs[1, 1].plot(x, -y, 'tab:red')
axs[1, 1].set_title('Axis [1, 1]')
for ax in axs.flat:
ax.set(xlabel='x-label', ylabel='y-label')
# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
ax.label_outer()
我现在的目标是以下形式的 3 个 supblots,但我没有在网络上找到可用的资源来获得这个:
【问题讨论】:
标签: python matplotlib subplot