2
可以使用参数horizontalalignment
(ha
)和verticalalignment
(va
)参数(例如,文本框)指定文本框的对齐方式。*边界框内的文本对齐*
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(8,5))
plt.subplots_adjust(right=0.5)
txt = "Test:\nthis is some text\ninside a bounding box."
fig.text(0.7, 0.5, txt, ha='left', va='center')
主要生产:
反正是有保持相同的包围盒(bbox
)对齐,而改变这种边界框内文本的对齐方式?例如文本要在边界框中居中。
(显然,在这种情况下,我可以只更换边界框,但在更复杂的情况,我想单独更改文本的对齐方式。)
这仍然会改变整个边界框,而不仅仅是其中的文本。 – DilithiumMatrix
有趣,谢谢。这基本上是我一直在使用的方法(除非我没有看到“倒转”方法 - 真的很酷!)。我猜这里没有任何内置的方法。 – DilithiumMatrix