matplotlib 表中的居中文本 [英] Centered text in matplotlib tables

查看:34
本文介绍了matplotlib 表中的居中文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将文本居中放置在 matplotlib 表格单元格中,而默认值似乎是右对齐的.我浏览了Table对象的文档,但是找不到任何有用的东西.

I am trying to center the text inside a matplotlib table cell, while the default seems to be right aligned. I looked through the documentation of the Table object, but I could not find anything useful in this.

有没有简单的方法来实现居中?

Is there an easy way to achieve the centering?

推荐答案

尝试编辑示例 here

添加

cellLoc='center'

收件人

the_table = plt.table(cellText=cell_text,
                      rowLabels=rows,
                      rowColours=colors,
                      colLabels=columns,
                      loc='bottom')

得到

这篇关于matplotlib 表中的居中文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆