|
11 | 11 | import numpy as np |
12 | 12 |
|
13 | 13 | from matplotlib.colors import Normalize |
| 14 | +from matplotlib.font_manager import FontProperties |
14 | 15 |
|
15 | | -from data_prototype.wrappers import FormattedText |
16 | | -from data_prototype.artist import CompatibilityArtist as CA |
| 16 | +from data_prototype.artist import CompatibilityAxes |
17 | 17 | from data_prototype.line import Line |
18 | 18 | from data_prototype.containers import ArrayContainer |
19 | 19 | from data_prototype.description import Desc |
20 | | -from data_prototype.conversion_node import FunctionConversionNode |
21 | 20 | from data_prototype.conversion_edge import FuncEdge |
| 21 | +from data_prototype.text import Text |
22 | 22 |
|
23 | 23 |
|
24 | 24 | cmap = plt.colormaps["viridis"] |
|
49 | 49 | ), |
50 | 50 | ] |
51 | 51 |
|
52 | | -text_converter = FunctionConversionNode.from_funcs( |
53 | | - { |
54 | | - "text": lambda j, cat: f"index={j[()]} class={cat!r}", |
55 | | - "y": lambda j: j, |
56 | | - "x": lambda x: 2 * np.pi, |
57 | | - }, |
58 | | -) |
| 52 | +text_edges = [ |
| 53 | + FuncEdge.from_func( |
| 54 | + "text", |
| 55 | + lambda j, cat: f"index={j[()]} class={cat!r}", |
| 56 | + {"j": Desc((), "auto"), "cat": Desc((), "auto")}, |
| 57 | + {"text": Desc((), "display")}, |
| 58 | + ), |
| 59 | + FuncEdge.from_func( |
| 60 | + "y", |
| 61 | + lambda j: j, |
| 62 | + {"j": Desc((), "auto")}, |
| 63 | + {"y": Desc((), "data")}, |
| 64 | + ), |
| 65 | + FuncEdge.from_func( |
| 66 | + "x", |
| 67 | + lambda: 2 * np.pi, |
| 68 | + {}, |
| 69 | + {"x": Desc((), "data")}, |
| 70 | + ), |
| 71 | + FuncEdge.from_func( |
| 72 | + "color", |
| 73 | + lambda: (0, 0, 0, 1), |
| 74 | + {}, |
| 75 | + {"color": Desc((4,), "rgba")}, |
| 76 | + ), |
| 77 | +] |
59 | 78 |
|
60 | 79 |
|
61 | 80 | th = np.linspace(0, 2 * np.pi, 128) |
62 | 81 | delta = np.pi / 9 |
63 | 82 |
|
64 | | -fig, ax = plt.subplots() |
| 83 | +fig, nax = plt.subplots() |
| 84 | + |
| 85 | +ax = CompatibilityAxes(nax) |
| 86 | +nax.add_artist(ax) |
65 | 87 |
|
66 | 88 | for j in range(10): |
67 | 89 | ac = ArrayContainer( |
|
74 | 96 | } |
75 | 97 | ) |
76 | 98 | ax.add_artist( |
77 | | - CA( |
78 | | - Line( |
79 | | - ac, |
80 | | - line_edges, |
81 | | - ) |
| 99 | + Line( |
| 100 | + ac, |
| 101 | + line_edges, |
82 | 102 | ) |
83 | 103 | ) |
84 | 104 | ax.add_artist( |
85 | | - FormattedText( |
| 105 | + Text( |
86 | 106 | ac, |
87 | | - text_converter, |
| 107 | + text_edges, |
88 | 108 | x=2 * np.pi, |
89 | | - ha="right", |
90 | | - bbox={"facecolor": "gray", "alpha": 0.5}, |
| 109 | + # ha="right", |
| 110 | + # bbox={"facecolor": "gray", "alpha": 0.5}, |
| 111 | + antialiased=False, |
| 112 | + fontproperties=FontProperties(), |
| 113 | + rotation=0, |
| 114 | + alpha=1, |
| 115 | + usetex=False, |
91 | 116 | ) |
92 | 117 | ) |
93 | 118 | ax.set_xlim(0, np.pi * 2) |
|
0 commit comments