2
繼pylab_examples,我在matplotlib創建了一個簡單的2×細胞表。如何分配在Matplotlib表特定顏色的特定細胞?
代碼:
# 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')
現在,我要的顏色單元格A1與color = "#56b5fd"
和單元格A2與color = "#1ac3f5"
。所有其他細胞應保持白色。 Matplotlib的table_demo.py以及this例如只告訴我如何應用彩色地圖依賴於細胞中的值預先定義的顏色。
如何分配在Matplotlib生成表的具體顏色以特定細胞?