Centered text in matplotlib tables

后端 未结 3 1706
故里飘歌
故里飘歌 2021-01-17 23:02

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 cou

3条回答
  •  误落风尘
    2021-01-17 23:52

    According to documentation, there is this metthod in cell object :

    set_text_props(self, **kwargs)
    

    kwargs may refers to text methods/attribute, such this one:

    horizontalalignment or ha = [ 'center' | 'right' | 'left' ]
    

    So, what about :

    cell.set_text_props(ha='center')
    

提交回复
热议问题