8000 DOC: Addressed issue #11092 · matplotlib/matplotlib@05dbb33 · GitHub
[go: up one dir, main page]

Skip to content

Commit 05dbb33

Browse files
committed
DOC: Addressed issue #11092
[ci skip] [skip ci]
1 parent 0722828 commit 05dbb33

File tree

2 files changed

+28
-119
lines changed

2 files changed

+28
-119
lines changed
Lines changed: 28 additions & 16 deletions
< 10000 /tr>
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
"""
2-
=======================
3-
Simple Anchored Artists
4-
=======================
5-
2+
================
3+
Anchored Artists
4+
================
65
"""
6+
77
import matplotlib.pyplot as plt
88

99

1010
def draw_text(ax):
11+
"""
12+
Draw two text-boxes, anchored by different corners to the upper-left
13+
side of the figure.
14+
"""
1115
from matplotlib.offsetbox import AnchoredText
16+
# loc=2 is equivalent to loc='upper left'
1217
at = AnchoredText("Figure 1a",
1318
loc=2, prop=dict(size=8), frameon=True,
1419
)
1520
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
1621
ax.add_artist(at)
1722

23+
# loc=3 is eqivalent to loc='lower left'
1824
at2 = AnchoredText("Figure 1(b)",
1925
loc=3, prop=dict(size=8), frameon=True,
2026
bbox_to_anchor=(0., 1.),
@@ -24,7 +30,10 @@ def draw_text(ax):
2430
ax.add_artist(at2)
2531

2632

27-
def draw_circle(ax): # circle in the canvas coordinate
33+
def draw_circle(ax):
34+
"""
35+
Draw a circle in axis coordinates
36+
"""
2837
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDrawingArea
2938
from matplotlib.patches import Circle
3039
ada = AnchoredDrawingArea(20, 20, 0, 0,
@@ -35,18 +44,22 @@ def draw_circle(ax): # circle in the canvas coordinate
3544

3645

3746
def draw_ellipse(ax):
47+
"""
48+
Draw an ellipse of width=0.1, height=0.15 in data coordinates
49+
"""
3850
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredEllipse
39-
# draw an ellipse of width=0.1, height=0.15 in the data coordinate
4051
ae = AnchoredEllipse(ax.transData, width=0.1, height=0.15, angle=0.,
4152
loc=3, pad=0.5, borderpad=0.4, frameon=True)
4253

4354
ax.add_artist(ae)
4455

4556

4657
def draw_sizebar(ax):
58+
"""
59+
Draw a horizontal bar with length of 0.1 in data coordinates,
60+
with a fixed label underneath.
61+
"""
4762
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
48-
# draw a horizontal bar with length of 0.1 in Data coordinate
49-
# (ax.transData) with a label underneath.
5063
asb = AnchoredSizeBar(ax.transData,
5164
0.1,
5265
r"1$^{\prime}$",
@@ -56,13 +69,12 @@ def draw_sizebar(ax):
5669
ax.add_artist(asb)
5770

5871

59-
if 1:
60-
ax = plt.gca()
61-
ax.set_aspect(1.)
72+
ax = plt.gca()
73+
ax.set_aspect(1.)
6274

63-
draw_text(ax)
64-
draw_circle(ax)
65-
draw_ellipse(ax)
66-
draw_sizebar(ax)
75+
draw_text(ax)
76+
draw_circle(ax)
77+
draw_ellipse(ax)
78+
draw_sizebar(ax)
6779

68-
plt.show()
80+
plt.show()

examples/misc/anchored_artists.py

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0