The Image class whose size is determined by the given bbox.
| 1214 | |
| 1215 | |
| 1216 | class BboxImage(_ImageBase): |
| 1217 | """The Image class whose size is determined by the given bbox.""" |
| 1218 | def __init__(self, bbox, |
| 1219 | cmap=None, |
| 1220 | norm=None, |
| 1221 | interpolation=None, |
| 1222 | origin=None, |
| 1223 | filternorm=1, |
| 1224 | filterrad=4.0, |
| 1225 | resample=False, |
| 1226 | interp_at_native=True, |
| 1227 | **kwargs |
| 1228 | ): |
| 1229 | """ |
| 1230 | cmap is a colors.Colormap instance |
| 1231 | norm is a colors.Normalize instance to map luminance to 0-1 |
| 1232 | |
| 1233 | interp_at_native is a flag that determines whether or not |
| 1234 | interpolation should still be applied when the image is |
| 1235 | displayed at its native resolution. A common use case for this |
| 1236 | is when displaying an image for annotational purposes; it is |
| 1237 | treated similarly to Photoshop (interpolation is only used when |
| 1238 | displaying the image at non-native resolutions). |
| 1239 | |
| 1240 | |
| 1241 | kwargs are an optional list of Artist keyword args |
| 1242 | |
| 1243 | """ |
| 1244 | super().__init__( |
| 1245 | None, |
| 1246 | cmap=cmap, |
| 1247 | norm=norm, |
| 1248 | interpolation=interpolation, |
| 1249 | origin=origin, |
| 1250 | filternorm=filternorm, |
| 1251 | filterrad=filterrad, |
| 1252 | resample=resample, |
| 1253 | **kwargs |
| 1254 | ) |
| 1255 | |
| 1256 | self.bbox = bbox |
| 1257 | self.interp_at_native = interp_at_native |
| 1258 | self._transform = IdentityTransform() |
| 1259 | |
| 1260 | def get_transform(self): |
| 1261 | return self._transform |
| 1262 | |
| 1263 | def get_window_extent(self, renderer=None): |
| 1264 | if renderer is None: |
| 1265 | renderer = self.get_figure()._cachedRenderer |
| 1266 | |
| 1267 | if isinstance(self.bbox, BboxBase): |
| 1268 | return self.bbox |
| 1269 | elif callable(self.bbox): |
| 1270 | return self.bbox(renderer) |
| 1271 | else: |
| 1272 | raise ValueError("unknown type of bbox") |
| 1273 |
no outgoing calls