【发布时间】:2018-03-21 16:39:14
【问题描述】:
按照 pylab_examples,我在 matplotlib 中创建了一个简单的 2x5 单元格表。
代码:
# Prepare table
columns = ('A', 'B', 'C', 'D', 'E')
rows = ["A", "B"]
cell_text = [["1", "1","1","1","1"], ["2","2","2","2","2"]]
# Add a table at the bottom of the axes
ax[4].axis('tight')
ax[4].axis('off')
the_table = ax[4].table(cellText=cell_text,colLabels=columns,loc='center')
现在,我想用color = "#56b5fd" 为单元格A1 着色,用color = "#1ac3f5" 为单元格A2 着色。所有其他单元格应保持白色。 Matplotlib 的 table_demo.py 和 this 示例仅向我展示了如何应用具有取决于单元格中值的预定义颜色的颜色图。
如何为 Matplotlib 生成的表格中的特定单元格分配特定颜色?
【问题讨论】:
标签: python matplotlib colors