Я создал 2 разных рисунка (Fig1 и Fig2) в mathplotlib и сохранил их в pdf. Кто-нибудь может мне помочь, как объединить эти две фигуры и создать одну фигуру. fig1 и fig2 имеют одинаковую ось X.
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
def lc_fslg(target,position,axes,titel,exc_true,l_pos):
for axi in axes:
pp = PdfPages('output\ ' + 'lc_over_fuselage_'+ axi + '.pdf')
plt.figure()
plt.axis('off')
plt.text(0.5, 0.5, titel+str(axi), ha='center', va='center')
pp.savefig()
plt.close()
for kind in ['ground','flight']:
plot_load_flow(target, position, kind, axi.lower(), titel, exc_true, l_pos)
plt.savefig(pp, format='pdf', papertype='a4', orientation='landscape', bbox_inches='tight')
plt.close('all')
pp.close()
def plot_load_flow(target,position,kind,axe,titel,exc_true,l_pos):
d_ax_label = {'tx': 'Tx [daN]', 'ty': 'Ty [daN]', 'tz': 'Tz [daN]'
, 'mx': 'Mx [daNm]', 'my': 'My [daNm]', 'mz': 'Mz [daNm]'}
max_v=[]
min_v=[]
max_vM=[]
min_vM=[]
pos_env=[]
if(kind == 'ground'):
for pos in l_pos:
load_at_pos = target.uload_at(pos)
max = load_at_pos[axe].loc[(load_at_pos['position'] == pos) & (load_at_pos['type'] == 'X')].max()
min = load_at_pos[axe].loc[(load_at_pos['position'] == pos) & (load_at_pos['type'] == 'X')].min()
if(not(np.isnan(max))& (not(np.isnan(min)))):
max_v.append(max)
min_v.append(min)
pos_env.append(pos)
x_env = [position[pos] for pos in pos_env]
plt.clf()
fig1 = plt.figure(figsize=(15, 15))
plt.plot(x_env, max_v, 'b-', markersize=15,linewidth=3.5, label='envelope '+str(kind))
plt.plot(x_env, min_v, 'b-', markersize=15,linewidth=3.5)
if(kind == 'flight'):
for pos in l_pos:
load_at_pos = target.uload_at(pos)
max = load_at_pos[axe].loc[(load_at_pos['position'] == pos)
& ((load_at_pos['type'] == 'G') | (load_at_pos['type'] == 'M'))].max()
min = load_at_pos[axe].loc[(load_at_pos['position'] == pos)
& ((load_at_pos['type'] == 'G') | (load_at_pos['type'] == 'M'))].min()
if (not (np.isnan(max)) & (not (np.isnan(min)))):
max_vM.append(max)
min_vM.append(min)
pos_env.append(pos)
x_env = [position[pos] for pos in pos_env]
plt.clf()
fig2 = plt.figure(figsize=(15, 15))
plt.plot(x_env, max_v, 'b-', markersize=15,linewidth=3.5, label='envelope '+str(kind))
plt.plot(x_env, min_v, 'b-', markersize=15,linewidth=3.5)
plt.plot(x_env, max_vM, 'g-', markersize=15,linewidth=3.5, label='envelope '+str(kind))
plt.plot(x_env, min_vM, 'g-', markersize=15,linewidth=3.5)
# define plot layout
plt.yticks(fontsize=20)
plt.ylabel(d_ax_label[axe], fontsize=30)
plt.xticks(fontsize=20)
plt.xticks(x_env,pos_env,fontsize=20,rotation='vertical')
plt.xlabel('frame position', fontsize=30)
plt.title(titel, fontsize=20)
legend = plt.legend(shadow=True, prop={'size': 20})
plt.grid(True)
plt.tight_layout()