我正在努力使 matplotlib 中的文本在填充空间后具有相同的视觉长度。它总是对我不起作用。
这是我尝试过的,
from matplotlib import pyplot as plt
fig = plt.figure()
plt.text(0,1,'how are you', bbox=dict(facecolor='red', alpha=0.5))
plt.text(0,0,'how'.ljust(len('how are you'), bbox=dict(facecolor='red', alpha=0.5))
plt.show()
Run Code Online (Sandbox Code Playgroud)
和想法?
谢谢!