自动换行文本 |
您所在的位置:网站首页 › 坐标轴的文字怎么自动换行 › 自动换行文本 |
笔记 单击此处 下载完整的示例代码 自动换行#Matplotlib 可以自动换行,但如果太长,文本将显示在轴边界之外。 注意:自动换行不能与 . 'tight' 设置重新调整画布以适应所有内容并在换行之前发生。这会影响 IPython 和 Jupyter 笔记本,其中在保存要嵌入的图像时默认使用内联设置。savefig(..., bbox_inches='tight')%matplotlib inlinebbox_inches='tight' 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, 4, t, family='serif', style='italic', ha='right', wrap=True) plt.text(-1, 0, t, ha='left', rotation=-15, wrap=True) plt.show()Download Python source code: autowrap.py Download Jupyter notebook: autowrap.ipynb 由 Sphinx-Gallery 生成的画廊 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |