- mcalf.utils.plot.calculate_extent(shape, resolution, offset=(0, 0), ax=None, dimension=None, **kwargs)
Calculate the extent from a particular data shape and resolution.
This function assumes a lower origin is being used with matplotlib.
resolution (tuple[float] or astropy.units.quantity.Quantity) – A 2-tuple (x, y) containing the length of each pixel in the x and y direction respectively. If a value has type
astropy.units.quantity.Quantity, its axis label will include its attached unit, otherwise the unit will default to Mm. The ax parameter must be specified to set its labels. If resolution is None, this function will immediately return None.
offset (tuple[float] or int, length=2, optional, default=(0, 0)) – Two offset values (x, y) for the x and y axis respectively. Number of pixels from the 0 pixel to the first pixel. Defaults to the first pixel being at 0 length units. For example, in a 1000 pixel wide dataset, setting offset to -500 would place the 0 Mm location at the centre.
ax (matplotlib.axes.Axes, optional, default=None) – Axes into which axis labels will be plotted. Defaults to not printing axis labels.
dimension (str or tuple[str] or list[str], length=2, optional, default=None) – If an ax (and resolution) is provided, use this string as the dimension name that appears before the
(unit)in the axis label. A 2-tuple (x, y) or list [x, y] can instead be given to provide a different name for the x-axis and y-axis respectively. Defaults is equivalent to
extent – The extent value that will be passed to matplotlib functions with a lower origin. Will return None if resolution is None.
- Return type