我有一个多轴图,左侧是水平条形图,右侧是与条形对应的文本。我正在循环创建其中的多个。右边的文字都是不同的长度。我怎样才能使它的 x 轴刻度对于每个图形都具有相同的位置?每个图的相位都会发生变化。我希望它类似于 URGN pic。我一直无法找到设置子图 x 轴的方法。谢谢您的帮助。
#WRITE PIPELINE
#variables
ppp = PipelineData['Ticker']
ccc = PipelineData['Catalyst']
cc = ccc.loc[ppp==i]
c = cc+str(" ")
dd = PipelineData['Drug']
d = dd.loc[ppp==i]
pp = PipelineData['Phase']
p = pp.loc[ppp==i]
disdis = PipelineData['Disease']
dis = disdis.loc[ppp==i]
#write graph
fuk = plt.figure(figsize=(18,6.7))
ax1 = fuk.add_subplot()
ax2 = ax1.twinx()
width = 0.5 # the width of the bars
ind = np.arange(len(p)) # the x locations for the groups
ax1.barh(ind, p, width, color="#67a362", align='edge')
ax1.set_yticks(ind+width)
ax1.set_yticklabels(d, minor=False)
ax1.set_ylabel('Drug')
ax1.set_xmargin(1.5)
ax1.autoscale_view()
ax2.set_ylim(ax1.get_ylim())
ax2.set_yticks(np.arange(len(c)) + width/2)
ax2.set_yticklabels(c,horizontalalignment = "right")
ax1.spines['right'].set_color('None')
#ax2.spines['right'].set_color('None')
plt.xticks(np.arange(5),('Pre-clinical','Phase I','Phase II','Phase III', 'Approved'))
plt.rcParams['axes.grid'] = False
ax1.grid(False)
ax2.grid(False)
ax1.set_facecolor('w')
ax2.set_facecolor('w')
for bar, disease in zip(ax1.patches, dis):
ax1.text(0.1, bar.get_y()+bar.get_height()/2, disease, color = 'black', ha = 'left', va = 'center')
fuk.suptitle(i)
fuk.savefig(str(i)+'newpipe.png', bbox_inches='tight')
ws.insert_image(row_pipe,col_pipe,str(i)+'newpipe.png',{'x_scale':.56, 'y_scale':.56})
row_pipe += 34
plt.close(fuk)