相关疑难解决方法(0)

换行文本在 matplotlib 中不起作用

我正在尝试使用 wrap=True 包装文本,但它似乎对我不起作用。从下面的 matplotlib 运行示例:

import matplotlib.pyplot as plt

fig = plt.figure()
plt.axis([0, 10, 0, 10])
t = "This is a really long string that I'd rather have wrapped so that it"\
    " doesn't go outside of the figure, but if it's long enough it will go"\
    " off the top or bottom!"
plt.text(4, 1, t, ha='left', rotation=15, wrap=True)
plt.text(6, 5, t, ha='left', rotation=15, wrap=True)
plt.text(5, 5, t, ha='right', rotation=-15, wrap=True)
plt.text(5, 10, t, fontsize=18, style='oblique', ha='center',
         va='top', wrap=True)
plt.text(3, …
Run Code Online (Sandbox Code Playgroud)

python text matplotlib

6
推荐指数
1
解决办法
1992
查看次数

标签 统计

matplotlib ×1

python ×1

text ×1