有没有办法用我已经制作的图表创建图表网格?

Is there a way to create a grid of graphs with plots I already made?

我正在尝试将 4 个绘图放在一个盒子中,并将所有 4 个绘图缩小到一个图像中。电子 我试图只输入我的地块名称作为参数(例如 wshot_plot),但这不起作用。

 fig, axs = plt.subplots(2, 2)
    axs[0, 0].plot(wshot_plot)
    axs[0, 0].set_title('Wrist')
    axs[0, 1].plot(slshot_plot)
    axs[0, 1].set_title('Slap')
    axs[1, 0].plot(snshot_plot)
    axs[1, 0].set_title('Snap')
    axs[1, 1].plot(tshot_plot)
    axs[1, 1].set_title('Tip-In')

知道我该怎么做吗?

期望的输出是这样的(当然有完整的图表)

这对你有用吗?

import numpy as np
from numpy import e, pi, sin, exp, cos
import matplotlib.pyplot as plt


a = [1.02, .95, .87, .77, .67, .46, .74, .60]
b = [0.39, .32, .27, .22, .18, .15, .13, .12]
c = [0.49, .42, .37, .32, .28, .35, .33, .52]
d = [0.29, .52, .47, .52, .58, .35, .43, .32]


python_course_green = "#476042"
fig = plt.figure(figsize=(6, 4))

t = np.arange(-5.0, 1.0, 0.1)

sub1 = fig.add_subplot(221) # instead of plt.subplot(2, 2, 1)
sub1.set_title('Something A') # non OOP: plt.title('The function f')
sub1.plot(a)


sub2 = fig.add_subplot(222, facecolor="lightgrey")
sub2.set_title('Something B')
sub2.plot(b)


t = np.arange(-3.0, 2.0, 0.02)
sub3 = fig.add_subplot(223)
sub3.set_title('Something C')
sub3.plot(c)

t = np.arange(-0.2, 0.2, 0.001)
sub4 = fig.add_subplot(224, facecolor="lightgrey")
sub4.set_title('Something D')
sub4.plot(d)



plt.tight_layout()
plt.show()

输出

希望能帮到你。