Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5aa407a

Browse files
committed
Remove unnecessary uses of transFigure from examples.
- In fig_x, fig.add_artist will adjust the artist's transform to fig.transFigure if it's not set yet. - In fancybox_demo, fig.text already defaults to using fig.transFigure. ... plus minor docstring edits.
1 parent 49decb4 commit 5aa407a

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

examples/pyplots/fig_x.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
66
Adding lines to a figure without any axes.
77
"""
8+
89
import matplotlib.pyplot as plt
910
import matplotlib.lines as lines
1011

1112

1213
fig = plt.figure()
13-
l1 = lines.Line2D([0, 1], [0, 1], transform=fig.transFigure, figure=fig)
14-
l2 = lines.Line2D([0, 1], [1, 0], transform=fig.transFigure, figure=fig)
15-
fig.lines.extend([l1, l2])
16-
14+
fig.add_artist(lines.Line2D([0, 1], [0, 1]))
15+
fig.add_artist(lines.Line2D([0, 1], [1, 0]))
1716
plt.show()
1817

1918
#############################################################################

examples/shapes_and_collections/fancybox_demo.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
"""
2-
=============
3-
Fancybox Demo
4-
=============
2+
===================
3+
Drawing fancy boxes
4+
===================
55
6-
Plotting fancy boxes with Matplotlib.
7-
8-
The following examples show how to plot boxes with different
9-
visual properties.
6+
The following examples show how to plot boxes with different visual properties.
107
"""
8+
119
import matplotlib.pyplot as plt
1210
import matplotlib.transforms as mtransforms
1311
import matplotlib.patches as mpatch
@@ -25,10 +23,9 @@
2523

2624
for i, stylename in enumerate(sorted(styles)):
2725
fig.text(0.5, (spacing * (len(styles) - i) - 0.5) / figheight, stylename,
28-
ha="center",
29-
size=fontsize,
30-
transform=fig.transFigure,
31-
bbox=dict(boxstyle=stylename, fc="w", ec="k"))
26+
ha="center",
27+
size=fontsize,
28+
bbox=dict(boxstyle=stylename, fc="w", ec="k"))
3229

3330
plt.show()
3431

0 commit comments

Comments
 (0)