Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitada3f9a

Browse files
committed
Added what's new entry and example for autowrapping text
1 parentabec281 commitada3f9a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎doc/users/whats_new/autowrap_text.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Auto-wrapping Text
2+
------------------
3+
Added the keyword argument "wrap" to Text, which automatically breaks long lines of text when being drawn.
4+
Works for any rotated text, different modes of alignment, and for text that are either labels or titles.
5+
6+
Example:
7+
plt.text(1, 1, "This is a really long string that should be wrapped so that it does not go outside the figure.", wrap=True)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Auto-wrapping text demo.
3+
"""
4+
importmatplotlib.pyplotasplt
5+
6+
fig=plt.figure()
7+
plt.axis([0,10,0,10])
8+
t="This is a really long string that I'd rather have wrapped so that it"\
9+
" doesn't go outside of the figure, but if it's long enough it will go"\
10+
" off the top or bottom!"
11+
plt.text(4,1,t,ha='left',rotation=15,wrap=True)
12+
plt.text(6,5,t,ha='left',rotation=15,wrap=True)
13+
plt.text(5,5,t,ha='right',rotation=-15,wrap=True)
14+
plt.text(5,10,t,fontsize=18,style='oblique',ha='center',
15+
va='top',wrap=True)
16+
plt.text(3,4,t,family='serif',style='italic',ha='right',wrap=True)
17+
plt.text(-1,0,t,ha='left',rotation=-15,wrap=True)
18+
19+
plt.show()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp