matplotlib - MatplotLib:一次格式化多个单元格
问题描述
这是我的 matplotlib 函数,用于格式化单元格的行或列:
def setRowWiseFont(table, rowIndices, fontWeight = None, fontColor = None, fontSize = None, fontAlignment = None):
# Font Size Ranges 6 - 72 pts. Including medium as string
#Alignments = 'center' | 'right' | 'left'
if fontAlignment == None:
fontAlignment = "center"
if fontColor == None:
fontColor = "black"
if fontSize == None:
fontSize = 6
if fontWeight == None:
fontWeight = "normal"
for (row, col), cell in table.get_celld().items():
if (row in rowIndices):
cell.set_text_props(fontproperties=FontProperties(weight=fontWeight, size = fontSize),ha = fontAlignment)
cell.get_text().set_color(fontColor)
return table
def setColumnWiseFont(table, colIndices, fontWeight = None, fontColor = None, fontSize = None, fontAlignment = None):
# Font Size Ranges 6 - 72 pts. Including medium as string
#Alignments = 'center' | 'right' | 'left'
if fontAlignment == None:
fontAlignment = "center"
if fontColor == None:
fontColor = "black"
if fontSize == None:
fontSize = 6
if fontWeight == None:
fontWeight = "normal"
for (row, col), cell in table.get_celld().items():
if (col in colIndices):
cell.set_text_props(fontproperties=FontProperties(weight=fontWeight, size = fontSize),ha = fontAlignment)
cell.get_text().set_color(fontColor)
plt.show()
return table
如您所见,我可以使用上述两个函数格式化多行和多列,但从性能方面来说,这个函数很慢。我对可以让我通过索引或其他东西一次格式化多个单元格的东西感兴趣。例如:
cell[0:3,4:6].format(<formatting parms here>)
有谁知道这样做的方法?
解决方案
推荐阅读
- python-3.x - 如何选择keras密集层的前k个元素?
- laravel - Laravel 如何跟踪批次值?
- amazon-web-services - 如何通过 ansible 在多个 EC2 实例上提供代码?
- php - 在 PHP 会话中未设置
- azure - Azure 函数 blob 触发器 - 对不同的主机名和函数的新版本使用相同的收据
- c++ - 如何将 std::array 转换为 boost::asio::buffer?
- makefile - 用于输入目标文件的 Makefile 配方问题
- android - 底部导航片段状态
- javascript - 函数从 API 端点返回数据后回调函数未接收数据
- java - 我无法在不包含任何客户端类的 wsdl 链接类中实现方法