Skip to content

Commit e4837b2

Browse files
committed
MNT: make clear all FormattedText objects share the same functions
1 parent fdf5e27 commit e4837b2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

examples/mapped.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
cmap.set_under("r")
2222
norm = Normalize(1, 8)
2323

24-
nus = {
24+
line_nus = {
2525
# arbitrary functions
2626
"lw": lambda lw: min(1 + lw, 5),
2727
# standard color mapping
@@ -30,6 +30,12 @@
3030
"ls": lambda cat: {"A": "-", "B": ":", "C": "--"}[cat[()]],
3131
}
3232

33+
text_nus = {
34+
"text": lambda j, cat: f"index={j[()]} class={cat[()]!r}",
35+
"y": lambda j: j,
36+
}
37+
38+
3339
th = np.linspace(0, 2 * np.pi, 128)
3440
delta = np.pi / 9
3541

@@ -48,13 +54,13 @@
4854
ax.add_artist(
4955
LineWrapper(
5056
ac,
51-
nus,
57+
line_nus,
5258
)
5359
)
5460
ax.add_artist(
5561
FormatedText(
5662
ac,
57-
{"text": lambda j, cat: f"index={j[()]} class={cat[()]!r}", "y": lambda j: j},
63+
text_nus,
5864
x=2 * np.pi,
5965
ha="right",
6066
bbox={"facecolor": "gray", "alpha": 0.5},

0 commit comments

Comments
 (0)