我对情节有些新意,所以我无法得到我需要的东西。
我需要绘制两组事物:
[ feature tfidf
0 mcf7 0.007547
1 metastasis 0.007431
2 cancer cell 0.007042
3 ci 0.007039
4 tnbc 0.006912
5 tumor 0.006792
6 reconstruction 0.006600
7 bc 0.005918
8 cell 0.005836
9 carcinoma 0.005750
10 95 ci 0.005493 (...),
feature tfidf
0 mouse 0.012150
1 htt 0.010618
2 mhtt 0.008620
3 r62 0.006896
4 mitochondrial 0.005861
5 autophagy 0.005534
6 mutant 0.005520
7 striatal 0.005422
8 r62 mouse 0.005150
9 repeat 0.004916
10 yac128 0.004827]
我从一个函数中获取了这些函数,我将提供给下一个函数:
def plot_tfidf_classfeats_h(dfs):
fig = plt.figure(figsize=(12, 9), facecolor="w")
x = np.arange(len(dfs[0]))
for i, df in enumerate(dfs):
ax = fig.add_subplot(1, len(dfs), i+1)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.set_frame_on(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.set_xlabel("Mean Tf-Idf Score", labelpad=16, fontsize=14)
ax.set_title("label = " + str(df.label), fontsize=16)
ax.ticklabel_format(axis='x', style='sci', scilimits=(-2,2))
ax.barh(x, df.tfidf, align='center', color='#3F5D7D')
ax.set_yticks(x)
ax.set_ylim([-1, x[-1]+1])
yticks = ax.set_yticklabels(df.feature)
plt.subplots_adjust(bottom=0.09, right=0.97, left=0.15, top=0.95, wspace=0.52)
plt.show()
该功能成功产生以下图:
问题是,我想强制两个子图具有相同的x轴度量,例如," 1e-2" (它不一定是这个值,我只是想确保两个图都有相同的数字,以便正确比较它们。)
提前感谢您的帮助。