Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.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 使用matplotlib.pyplot在表中按列打印列表_Python_Matplotlib - Fatal编程技术网

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()
您需要以正确的格式获取数据