Python 使用matplotlib.pyplot在表中按列打印列表
我有两个列表需要根据其列标题绘制为表格:Python 使用matplotlib.pyplot在表中按列打印列表,python,matplotlib,Python,Matplotlib,我有两个列表需要根据其列标题绘制为表格: import matplotlib.pyplot as plt columnheaders=('Question Text', 'Answer Status') data_list_1=['hi','name pleas','how are you'] data_list_2=['answered','notanswered','answered'] **##the_table=ax.table(cellText
import matplotlib.pyplot as plt
columnheaders=('Question Text', 'Answer Status')
data_list_1=['hi','name pleas','how are you']
data_list_2=['answered','notanswered','answered']
**##the_table=ax.table(cellText=data_list,colLabels=columns,)**
ax.axis("off")
the_table.set_fontsize(14)
the_table.scale(1.5, 1.5)
plt.show()
如何将数据_list_1和数据_list_2传递给ax.table()函数,以便获得以下格式的表:
Question text answer status
hi answered
name please not answered
how are you answered
试试这个
import matplotlib.pyplot as plt
columnheaders=['Question Text', 'Answer Status']
data_list_1=['hi','name pleas','how are you']
data_list_2=['answered','notanswered','answered']
l = [data_list_1, data_list_2]
l = list(map(list, zip(*l)))
the_table=plt.table(cellText=l,loc='top', colLabels = columnheaders, cellLoc='center')
plt.axis("off")
the_table.set_fontsize(14)
the_table.scale(2, 7)
plt.show()
您需要以正确的格式获取数据