Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在matplot中绘制指向表内单元格的箭头_Python_Matlab_Matplotlib_Bioinformatics_Matplotlib Animation - Fatal编程技术网

Python 如何在matplot中绘制指向表内单元格的箭头

Python 如何在matplot中绘制指向表内单元格的箭头,python,matlab,matplotlib,bioinformatics,matplotlib-animation,Python,Matlab,Matplotlib,Bioinformatics,Matplotlib Animation,我想实现这样的目标: 我尝试使用此函数绘制箭头: plt.箭头(0.02,-0.02,-0.002,0.002,宽度=0.0005) 但问题是,当表格变大时,它的位置相对于X和Y轴发生变化,因此我需要一种方法使箭头指向单元格本身,而不是X和Y坐标 完整代码: fig, ax = plt.subplots() fig.patch.set_visible(False) #ax.axis('off') ax.axis('tight') df = pd.DataFrame(matrix, column

我想实现这样的目标:

我尝试使用此函数绘制箭头: plt.箭头(0.02,-0.02,-0.002,0.002,宽度=0.0005)

但问题是,当表格变大时,它的位置相对于X和Y轴发生变化,因此我需要一种方法使箭头指向单元格本身,而不是X和Y坐标

完整代码:

fig, ax = plt.subplots()
fig.patch.set_visible(False)
#ax.axis('off')
ax.axis('tight')
df = pd.DataFrame(matrix, columns=list(" " + sequence_a))

colors = [['w'] * N for _ in range(M)]

# COLOR THE MAP
x = [j for sub in queues for j in sub]
for i in range(M):
    for j in range(N):
        if (i, j) in x:
            colors[i][j] = 'g'

ax.table(cellText=df.values, colLabels=df.columns,
         loc='center', rowLabels=" " + sequence_b,
         cellColours=colors, colWidths=[0.05 for x in df.columns], )
plt.arrow(0.02, -0.02, -0.002, 0.002, width=0.0005)
fig.tight_layout()
plt.show()
其中矩阵是包含数字的列表(表),我还有一个包含箭头数据的字典(哪个单元格索引指向哪个)

完整项目github链接: