我想要在一块地块上绘制许多数据集.目前,为了测试我的曲线图,我已经对20个数据集进行了硬编码.以下是简短的代码:
import numpy as np
import matplotlib as plt
N_steps = 1000
N_plot = 20
xorb_list = np.empty((N_plot, N_steps))
yorb_list = np.empty((N_plot, N_steps))
xobs = np.empty((N_plot, N_steps))
yobs = np.empty((N_plot, N_steps))
zobs = np.empty((N_plot, N_steps))
for i in range(N_plot):
for k in range(N_steps):
xorb_list[i][k] = r[k] * cm_to_arcsec * cos_theta[k]
yorb_list[i][k] = r[k] * cm_to_arcsec * sin_theta[k]
xobs[i][k] = r[k] * (cos_lon * cos_w_plus_nu[k] - sin_lon * sin_w_plus_nu[k] * cos_i)
yobs[i][k] = r[k] * (sin_lon * cos_w_plus_nu[k] + cos_lon * sin_w_plus_nu[k] * cos_i)
zobs[i][k] = r[k] * sin_i * sin_w_plus_nu[k]
# Plotting the observed orbits
fig1 = plt.figure(1)
ax1 = fig1.add_subplot()
ax1.set_aspect(1)
ax1.set_title("Observed Stellar Orbits")
ax1.plot(xobs[0], yobs[0])
ax1.plot(xobs[1], yobs[1])
ax1.plot(xobs[2], yobs[2])
ax1.plot(xobs[3], yobs[3])
ax1.plot(xobs[4], yobs[4])
ax1.plot(xobs[5], yobs[5])
ax1.plot(xobs[6], yobs[6])
ax1.plot(xobs[7], yobs[7])
ax1.plot(xobs[8], yobs[8])
ax1.plot(xobs[9], yobs[9])
ax1.plot(xobs[10], yobs[10])
ax1.plot(xobs[11], yobs[11])
ax1.plot(xobs[12], yobs[12])
ax1.plot(xobs[13], yobs[13])
ax1.plot(xobs[14], yobs[14])
ax1.plot(xobs[15], yobs[15])
ax1.plot(xobs[16], yobs[16])
ax1.plot(xobs[17], yobs[17])
ax1.plot(xobs[18], yobs[18])
ax1.plot(xobs[19], yobs[19])
plt.show()
数据集的总数将在100左右,这对于硬编码来说将不是一件有趣的事情.有没有某种方法可以为任意数量的集合生成这些数据集?