I am trying to add a table of data summaries to the plot that I create like this:
import matplotlib.pyplot as plt
plt.figure()
plt.plot([0,2], [0,2])
plt.grid('on')
values = [[0,1],[2,3]]
rowLabels = ['row1', 'row2']
colLabels = ['col1', 'col2']
table = plt.table(cellText=values, colWidths=[0.1]*3, rowLabels = rowLabels,
colLabels=colLabels, loc = 'center right')
But where the grid and the table overlap, the grid is still visible, making it difficult to read the table.
So, I tried adding this code to set the background of the table cells to white and opaque, for example:
cells = table.get_celld()
for cell in cells:
cells[cell].set_facecolor('white')
cells[cell].set_alpha(1)
But that does not change. If I use a color other than white, I see that it sets the color of the cell, but the grid is still visible, which makes me think that the grid is drawn on top of the table and not behind it.
Does anyone know how to get a table on a chart with a grid, but keep the grid from the table?
Thanks!
Using the current latest matplotlib: version 1.3.1
source
share