matplotlib文字大小[左,下,宽,高](matplotlib Text size [left, bottom, width, height])

编程入门 行业动态 更新时间:2024-10-28 12:15:53
matplotlib文字大小[左,下,宽,高](matplotlib Text size [left, bottom, width, height])

我想知道如何准确计算matplotlib.Text的大小。

# this gives the position of the center of the text in the figure xy = text.get_position() # text size like in axes.get_position() [left, bottom, width, height] = text.???

对于文本,它可能更复杂,因为所有都取决于字体,fontsize等。我在想我可以使用text.get_bbox_patch()或text.get_clip_box()但两者都返回None

I wonder how to calculate exactly the size of a matplotlib.Text.

# this gives the position of the center of the text in the figure xy = text.get_position() # text size like in axes.get_position() [left, bottom, width, height] = text.???

For the text it might be more complicated because all depends on the font, fontsize etc. I was thinking that I can use text.get_bbox_patch() or text.get_clip_box() but both return None

最满意答案

text.get_window_extent()是要走的路。

由于某些原因,text.get_bbox_path()始终返回None

text.get_window_extent() is the way to go.

for some reasons text.get_bbox_path() is always returning None

更多推荐

本文发布于:2023-08-07 23:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466364.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文字大小   size   Text   matplotlib   width

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!