Process a matplotlib collection and call renderer.draw_collection
(
self, ax, collection, force_pathtrans=None, force_offsettrans=None
)
| 248 | ) |
| 249 | |
| 250 | def draw_collection( |
| 251 | self, ax, collection, force_pathtrans=None, force_offsettrans=None |
| 252 | ): |
| 253 | """Process a matplotlib collection and call renderer.draw_collection""" |
| 254 | (transform, transOffset, offsets, paths) = collection._prepare_points() |
| 255 | |
| 256 | offset_coords, offsets = self.process_transform( |
| 257 | transOffset, ax, offsets, force_trans=force_offsettrans |
| 258 | ) |
| 259 | path_coords = self.process_transform(transform, ax, force_trans=force_pathtrans) |
| 260 | |
| 261 | processed_paths = [utils.SVG_path(path) for path in paths] |
| 262 | processed_paths = [ |
| 263 | ( |
| 264 | self.process_transform( |
| 265 | transform, ax, path[0], force_trans=force_pathtrans |
| 266 | )[1], |
| 267 | path[1], |
| 268 | ) |
| 269 | for path in processed_paths |
| 270 | ] |
| 271 | |
| 272 | path_transforms = collection.get_transforms() |
| 273 | try: |
| 274 | # matplotlib 1.3: path_transforms are transform objects. |
| 275 | # Convert them to numpy arrays. |
| 276 | path_transforms = [t.get_matrix() for t in path_transforms] |
| 277 | except AttributeError: |
| 278 | # matplotlib 1.4: path transforms are already numpy arrays. |
| 279 | pass |
| 280 | |
| 281 | styles = { |
| 282 | "linewidth": collection.get_linewidths(), |
| 283 | "facecolor": collection.get_facecolors(), |
| 284 | "edgecolor": collection.get_edgecolors(), |
| 285 | "alpha": collection._alpha, |
| 286 | "zorder": collection.get_zorder(), |
| 287 | } |
| 288 | |
| 289 | # TODO: When matplotlib's minimum version is bumped to 3.8, this can be |
| 290 | # simplified since collection.get_offset_position no longer exists. |
| 291 | offset_dict = {"data": "before", "screen": "after"} |
| 292 | offset_order = ( |
| 293 | offset_dict[collection.get_offset_position()] |
| 294 | if hasattr(collection, "get_offset_position") |
| 295 | else "after" |
| 296 | ) |
| 297 | |
| 298 | self.renderer.draw_path_collection( |
| 299 | paths=processed_paths, |
| 300 | path_coordinates=path_coords, |
| 301 | path_transforms=path_transforms, |
| 302 | offsets=offsets, |
| 303 | offset_coordinates=offset_coords, |
| 304 | offset_order=offset_order, |
| 305 | styles=styles, |
| 306 | mplobj=collection, |
| 307 | ) |
no test coverage detected