Handler for `.Line2D` instances. See Also -------- HandlerLine2DCompound : An earlier handler implementation, which used one artist for the line and another for the marker(s).
| 273 | |
| 274 | |
| 275 | class HandlerLine2D(HandlerNpoints): |
| 276 | """ |
| 277 | Handler for `.Line2D` instances. |
| 278 | |
| 279 | See Also |
| 280 | -------- |
| 281 | HandlerLine2DCompound : An earlier handler implementation, which used one |
| 282 | artist for the line and another for the marker(s). |
| 283 | """ |
| 284 | |
| 285 | def create_artists(self, legend, orig_handle, |
| 286 | xdescent, ydescent, width, height, fontsize, |
| 287 | trans): |
| 288 | # docstring inherited |
| 289 | xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, |
| 290 | width, height, fontsize) |
| 291 | |
| 292 | markevery = None |
| 293 | if self.get_numpoints(legend) == 1: |
| 294 | # Special case: one wants a single marker in the center |
| 295 | # and a line that extends on both sides. One will use a |
| 296 | # 3 points line, but only mark the #1 (i.e. middle) point. |
| 297 | xdata = np.linspace(xdata[0], xdata[-1], 3) |
| 298 | markevery = [1] |
| 299 | |
| 300 | ydata = np.full_like(xdata, (height - ydescent) / 2) |
| 301 | legline = Line2D(xdata, ydata, markevery=markevery) |
| 302 | |
| 303 | self.update_prop(legline, orig_handle, legend) |
| 304 | |
| 305 | if legend.markerscale != 1: |
| 306 | newsz = legline.get_markersize() * legend.markerscale |
| 307 | legline.set_markersize(newsz) |
| 308 | |
| 309 | legline.set_transform(trans) |
| 310 | |
| 311 | return [legline] |
| 312 | |
| 313 | |
| 314 | class HandlerPatch(HandlerBase): |
no outgoing calls
no test coverage detected
searching dependent graphs…