首页 > 解决方案 > Python 无论如何要在矩阵中显示序列标签 TCAG?全球对齐

问题描述

无论如何,我可以在 python 代码中显示这些标签吗? 例子

    %matplotlib inline 
import matplotlib.pyplot as plt

plt.figure(figsize=(25,25))
plt.imshow(alignment_matrix, cmap='Pastel1')
plt.title("Alignment Matrix", size=30)

tick_marks = np.arange(0)
#plt.xticks(tick_marks, [sequence_1[0], sequence_1[1], sequence_1[2], sequence_1[3]], size=10)
#plt.yticks(tick_marks, [sequence_2[0], sequence_2[1], sequence_2[2], sequence_2[3]], size=10)
plt.xticks(tick_marks)
plt.yticks(tick_marks)
#plt.tight_layout()
plt.xlabel("Sequence 1", size=20)
plt.ylabel("Sequence 2", size=20)

w, h = alignment_matrix.shape
for x in range(w):
    for y in range(h):
        plt.annotate(str(alignment_matrix[x][y]), xy=(y,x), horizontalalignment='center', verticalalignment='center', size=20)
plt.show()

我的代码只会显示数字但没有标签输出

该序列从 txt 文件中读取,并赋值为字符串值。 序列分配

此代码的链接:https ://drive.google.com/file/d/1HXoB8zWUvwyCViORIKesjrkmj7VVOvOE/view?usp=sharing

标签: pythonmatplotlibbioinformatics

解决方案


推荐阅读