@@ -91,3 +91,83 @@ def draw(self, renderer, edges=None):
91
91
)
92
92
93
93
self ._artist .draw (renderer , edges )
94
+
95
+
96
+ class CompatibilityAxes :
97
+ """A compatibility shim to add to traditional matplotlib axes.
98
+
99
+ At this time features are implemented on an "as needed" basis, and many
100
+ are only implemented insofar as they do not fail, not necessarily providing
101
+ full functionality of a full MPL Artist.
102
+
103
+ The idea is to keep the new Artist class as minimal as possible.
104
+ As features are added this may shrink.
105
+
106
+ The main thing we are trying to avoid is the reliance on the axes/figure
107
+
108
+ Ultimately for useability, whatever remains shimmed out here may be rolled in as
109
+ some form of gaurded option to ``Artist`` itself, but a firm dividing line is
110
+ useful for avoiding accidental dependency.
111
+ """
112
+
113
+ def __init__ (self , axes ):
114
+ self .axes = axes
115
+ self .figure = None
116
+ self ._clippath = None
117
+ self .zorder = 2
118
+ self ._children = []
119
+
120
+ def set_figure (self , fig ):
121
+ self .figure = fig
122
+
123
+ def is_transform_set (self ):
124
+ return True
125
+
126
+ def get_mouseover (self ):
127
+ return False
128
+
129
+ def get_clip_path (self ):
130
+ self ._clippath
131
+
132
+ def set_clip_path (self , path ):
133
+ self ._clippath = path
134
+
135
+ def get_animated (self ):
136
+ return False
137
+
138
+ def draw (self , renderer , edges = None ):
139
+ if edges is None :
140
+ edges = []
141
+
142
+ if self .axes is not None :
143
+ desc : Desc = Desc (("N" ,), coordinates = "data" )
144
+ xy : dict [str , Desc ] = {"x" : desc , "y" : desc }
145
+ edges .append (
146
+ TransformEdge (
147
+ "data" ,
148
+ xy ,
149
+ desc_like (xy , coordinates = "axes" ),
150
+ transform = self .axes .transData - self .axes .transAxes ,
151
+ )
152
+ )
153
+ edges .append (
154
+ TransformEdge (
155
+ "axes" ,
156
+ desc_like (xy , coordinates = "axes" ),
157
+ desc_like (xy , coordinates = "display" ),
158
+ transform = self .axes .transAxes ,
159
+ )
160
+ )
161
+
162
+ # TODO independent zorder
163
+ for c in self ._children :
164
+ c .draw (renderer , edges )
165
+
166
+ def add_artist (self , artist ):
167
+ self ._children .append (artist )
168
+
169
+ def set_xlim (self , min_ = None , max_ = None ):
170
+ self .axes .set_xlim (min_ , max_ )
171
+
172
+ def set_ylim (self , min_ = None , max_ = None ):
173
+ self .axes .set_ylim (min_ , max_ )
0 commit comments