Matplotlib 函数中的多个(独立)PyPlot
我有两个数字,我想独立绘制。被调用函数(Propagate_TLE)创建的小图形需要绘制、保存和关闭,而main中的图形需要打开。当我尝试这样做时,对函数中图形的最后一次调用将覆盖main中的图形。我如何创造出彼此不冲突的独立人物Matplotlib 函数中的多个(独立)PyPlot,matplotlib,figure,Matplotlib,Figure,我有两个数字,我想独立绘制。被调用函数(Propagate_TLE)创建的小图形需要绘制、保存和关闭,而main中的图形需要打开。当我尝试这样做时,对函数中图形的最后一次调用将覆盖main中的图形。我如何创造出彼此不冲突的独立人物 def propagate_TLE(sat_tle,ID): plt.figure(figsize=(6,5)) ax = plt.subplot(111, projection='polar')
def propagate_TLE(sat_tle,ID):
plt.figure(figsize=(6,5))
ax = plt.subplot(111, projection='polar')
ax.scatter(sat_az,sat_alt,marker ='o', color ='blue')
plt.savefig((str(ID)).strip()+'_visibility.png')
plt.close
def main():
fig, ax1 = plt.subplots()
ax1.set_title('Schedule')
#Do the business of incrementing time and outputting positions for each satellite
for satellite in Sat_dict.keys():
colors,time_unit,ID = propagate_TLE(Sat_dict[satellite],satellite)
#create a bar-like graph of the satellite schedule
ID = [ ID for i in range(round(total_propagation))]
ax1.scatter(time_unit,ID,color=colors,marker='s')
plt.savefig('Satellite_schedule.png')
return
请原谅我没有包含无关代码。我怀疑有一种方法可以设置数字,这样它们就不会冲突。在上面,我结束了在Propagate_TLE中为“Satellite_schedule.png”创建的最后一个极坐标图。任何帮助都将不胜感激