Return a new transform with an added offset. Parameters ---------- trans : `Transform` subclass Any transform, to which offset will be applied. fig : `~matplotlib.figure.Figure`, default: None Current figure. It can be None if *units* are 'dots'. x, y : floa
(trans, fig=None, x=0.0, y=0.0, units='inches')
| 3021 | |
| 3022 | |
| 3023 | def offset_copy(trans, fig=None, x=0.0, y=0.0, units='inches'): |
| 3024 | """ |
| 3025 | Return a new transform with an added offset. |
| 3026 | |
| 3027 | Parameters |
| 3028 | ---------- |
| 3029 | trans : `Transform` subclass |
| 3030 | Any transform, to which offset will be applied. |
| 3031 | fig : `~matplotlib.figure.Figure`, default: None |
| 3032 | Current figure. It can be None if *units* are 'dots'. |
| 3033 | x, y : float, default: 0.0 |
| 3034 | The offset to apply. |
| 3035 | units : {'inches', 'points', 'dots'}, default: 'inches' |
| 3036 | Units of the offset. |
| 3037 | |
| 3038 | Returns |
| 3039 | ------- |
| 3040 | `Transform` subclass |
| 3041 | Transform with applied offset. |
| 3042 | """ |
| 3043 | _api.check_in_list(['dots', 'points', 'inches'], units=units) |
| 3044 | if units == 'dots': |
| 3045 | return trans + Affine2D().translate(x, y) |
| 3046 | if fig is None: |
| 3047 | raise ValueError('For units of inches or points a fig kwarg is needed') |
| 3048 | if units == 'points': |
| 3049 | x /= 72.0 |
| 3050 | y /= 72.0 |
| 3051 | # Default units are 'inches' |
| 3052 | return trans + ScaledTranslation(x, y, fig.dpi_scale_trans) |
nothing calls this directly
no test coverage detected
searching dependent graphs…