8000 update .rst · matplotlib/matplotlib@5770305 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5770305

Browse files
stevezhangstevezhang
authored andcommitted
update .rst
1 parent 827ab7b commit 5770305

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed
Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
Support customizing antialiasing for text and annotation
2-
~~~~~~~~~~~~~~~~~~~~~~~~
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4-
APIs:
5-
https://matplotlib.org/stable/api/text_api.html#matplotlib.text.Text
6-
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.annotate.html
74

8-
Text objects and annotation objects now support parameter `antialiased`.
9-
When `antialiased` is set to `True`, antialiasing will be applied to the text.
10-
When `antialiased` is set to `False`, antialiasing will be applied to the text.
11-
When `antialiased` is not specified, it will use the value from `rcParams['text.antialiased']`.
5+
6+
``matplotlib.pyplot.annotate()`` and ``matplotlib.pyplot.text()`` now support parameter ``antialiased``.
7+When ``antialiased`` is set to ``True``, antialiasing will be applied to the text.
8+
When ``antialiased`` is set to ``False``, antialiasing will be applied to the text.
9+
When ``antialiased`` is not specified, it will use the value from ``rcParams['text.antialiased']``.
1210

1311
Examples:
14-
```
15-
mpl.text.Text(.5, .5, "foo\nbar", antialiased=True)
16-
plt.text(0.5, 0.5, '6 inches x 2 inches', antialiased=True)
17-
ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5), antialiased=False)
18-
```
1912

20-
If the text contains math expression, then anaialiasing will be applied by `rcParams['text.antialiased']` and `antialiased` will have no effect
13+
.. code-block::
14+
15+
mpl.text.Text(.5, .5, "foo\nbar", antialiased=True)
16+
plt.text(0.5, 0.5, '6 inches x 2 inches', antialiased=True)
17+
ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5), antialiased=False)
18+
19+
If the text contains math expression, then anaialiasing will be applied by ``rcParams['text.antialiased']`` and ``antialiased`` will have no effect
2120
This applies to the whole text.
2221
Examples:
23-
```
24-
plt.text(0.5, 0.25, r"$I'm \sqrt{x}$", antialiased=False)
25-
```
2622

27-
Also note that antialiasing for coordinate axes will be set with `rcParams['text.antialiased']` when they are created and cannot be changed afterwards.
23+
.. code-block::
2824
29-
With this new feature, you may want to make sure that you are creating and saving/showing the figure under the same context:
30-
```
31-
# previously this was a no-op, now it is what works
32-
with rccontext(text.antialiased=False):
33-
fig, ax = plt.subplots()
34-
ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5))
35-
fig.savefig('/tmp/test.png')
25+
plt.text(0.5, 0.25, r"$I'm \sqrt{x}$", antialiased=False)
3626
27+
Also note that antialiasing for coordinate axes will be set with ``rcParams['text.antialiased']`` when they are created and cannot be changed afterwards.
3728

38-
# previously this had an effect, now this is a no-op
39-
fig, ax = plt.subplots()
40-
ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5))
41-
with rccontext(text.antialiased=False):
42-
fig.savefig('/tmp/test.png')
43-
```
29+
With this new feature, you may want to make sure that you are creating and saving/showing the figure under the same context::
30+
31+
# previously this was a no-op, now it is what works
32+
with rccontext(text.antialiased=False):
33+
fig, ax = plt.subplots()
34+
ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5))
35+
fig.savefig('/tmp/test.png')
36+
37+
38+
# previously this had an effect, now this is a no-op
39+
fig, ax = plt.subplots()
40+
ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5))
41+
with rccontext(text.antialiased=False):
42+
fig.savefig('/tmp/test.png')

0 commit comments

Comments
 (0)
0