问题
A table is created in a figure. Now I want to edit the table after double click at the cell, adding, deleting or revising the data in this cell. Just like the edit function in Excel. My python version is 3.64. Codes are following:
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
# Hide axes
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
# Table from Ed Smith answer
clust_data = [[1,1,7]]
collabel=("col 1", "col 2", "col 3")
ax.table(cellText=clust_data,colLabels=collabel,loc='center')
plt.show()
回答1:
It seems that you this is not easy to achieve using pure matplotlib functional.
You should consider looking at qgrid module, which provides interactive Excel-like table editing in Jupyter Notebook.
Then, if you want to change your graph accordingly, you will need to create some interaction with the table. ipywidgets can really help you with that.
来源:https://stackoverflow.com/questions/49848575/how-to-edit-table-data-with-interactive-event-in-matplotlib