Render the plate in the given axes. :param ctx: The :class:`_rendering_context` object.
(self, ctx)
| 1084 | self.position = position |
| 1085 | |
| 1086 | def render(self, ctx): |
| 1087 | """ |
| 1088 | Render the plate in the given axes. |
| 1089 | |
| 1090 | :param ctx: |
| 1091 | The :class:`_rendering_context` object. |
| 1092 | |
| 1093 | """ |
| 1094 | ax = ctx.ax() |
| 1095 | |
| 1096 | shift = np.array([0, self.shift], dtype=np.float64) |
| 1097 | rect = np.atleast_1d(self.rect) |
| 1098 | bottom_left = ctx.convert(*(rect[:2] + shift)) |
| 1099 | top_right = ctx.convert(*(rect[:2] + rect[2:])) |
| 1100 | rect = np.concatenate([bottom_left, top_right - bottom_left]) |
| 1101 | |
| 1102 | if self.rect_params is not None: |
| 1103 | rect_params = self.rect_params |
| 1104 | else: |
| 1105 | rect_params = {} |
| 1106 | |
| 1107 | rect_params["ec"] = _pop_multiple(rect_params, "k", "ec", "edgecolor") |
| 1108 | rect_params["fc"] = _pop_multiple( |
| 1109 | rect_params, "none", "fc", "facecolor" |
| 1110 | ) |
| 1111 | rect_params["lw"] = _pop_multiple( |
| 1112 | rect_params, ctx.line_width, "lw", "linewidth" |
| 1113 | ) |
| 1114 | rectangle = Rectangle(rect[:2], *rect[2:], **rect_params) |
| 1115 | |
| 1116 | ax.add_artist(rectangle) |
| 1117 | |
| 1118 | if self.label is not None: |
| 1119 | offset = np.array(self.label_offset, dtype=np.float64) |
| 1120 | if "left" in self.position: |
| 1121 | position = rect[:2] |
| 1122 | ha = "left" |
| 1123 | elif "right" in self.position: |
| 1124 | position = rect[:2] |
| 1125 | position[0] += rect[2] |
| 1126 | ha = "right" |
| 1127 | offset[0] = -offset[0] |
| 1128 | elif "center" in self.position: |
| 1129 | position = rect[:2] |
| 1130 | position[0] = rect[2] / 2 + rect[0] |
| 1131 | ha = "center" |
| 1132 | else: |
| 1133 | raise RuntimeError( |
| 1134 | "Unknown positioning string: {0}".format(self.position) |
| 1135 | ) |
| 1136 | |
| 1137 | if "bottom" in self.position: |
| 1138 | va = "bottom" |
| 1139 | elif "top" in self.position: |
| 1140 | position[1] = rect[1] + rect[3] |
| 1141 | offset[1] = -offset[1] - 0.1 |
| 1142 | va = "top" |
| 1143 | elif "middle" in self.position: |
nothing calls this directly
no test coverage detected