我正在尝试将4个地块放到一个盒子中,将所有4个缩小到一个图像中。e我想仅输入图的名称作为参数(例如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()
输出
希望我能帮到你。
np.arange有什么用?
使用.arrange()函数,您可以自定义x和y轴上的步骤。-> ibb.co/nz80ts0