我试图调整此表以便占用整个窗口,但顶部,左下和右下滑块的组合不允许我这样做,他们所做的只是在翻译时缩小网格。 / p>
有没有办法垂直拉伸?
这是我的代码:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors
from random import randint
def colour(value):
r,g,b = 0,0,0
if value < 1:
r = 1
g = 1*value
if value > 1:
r = 1 - 1*(value-1)
g = 1
if value == 1:
r = 1
g = 1
if value > 2:
b = 1
colour = (r,g,b)
return colour
ncols, nrows = 7,8
row= [[]]*nrows
for i in range(nrows):
row[i] = i*3
print(row)
col = ['M', 'T', 'W', 'Th', 'F', 'Sat', 'Sun']
list = []
text = ['','','','','','','']
for a in range(nrows):
list.append(text)
fig, ax = plt.subplots()
ax.axis('tight')
ax.axis('off')
image = ax.table(cellText=list, colLabels = col, rowLabels=row)
for j in range(ncols):
for i in range(nrows):
print(i,j)
value = randint(0,200)
value = value / 100
image._cells[(i+1,j)].set_facecolor(colour(value))
figManager = plt.get_current_fig_manager()
figManager.window.showMaximized()
fig.tight_layout()
plt.show()