MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_extent

Method set_extent

lib/matplotlib/image.py:943–989  ·  view source on GitHub ↗

Set the image extent. Parameters ---------- extent : 4-tuple of float The position and size of the image as tuple ``(left, right, bottom, top)`` in data coordinates. **kwargs Other parameters from which unit info (i.e., th

(self, extent, **kwargs)

Source from the content-addressed store, hash-verified

941 return self.get_interpolation() == "none"
942
943 def set_extent(self, extent, **kwargs):
944 """
945 Set the image extent.
946
947 Parameters
948 ----------
949 extent : 4-tuple of float
950 The position and size of the image as tuple
951 ``(left, right, bottom, top)`` in data coordinates.
952 **kwargs
953 Other parameters from which unit info (i.e., the *xunits*,
954 *yunits*, *zunits* (for 3D Axes), *runits* and *thetaunits* (for
955 polar Axes) entries are applied, if present.
956
957 Notes
958 -----
959 This updates `.Axes.dataLim`, and, if autoscaling, sets `.Axes.viewLim`
960 to tightly fit the image, regardless of `~.Axes.dataLim`. Autoscaling
961 state is not changed, so a subsequent call to `.Axes.autoscale_view`
962 will redo the autoscaling in accord with `~.Axes.dataLim`.
963 """
964 (xmin, xmax), (ymin, ymax) = self.axes._process_unit_info(
965 [("x", [extent[0], extent[1]]),
966 ("y", [extent[2], extent[3]])],
967 kwargs)
968 if kwargs:
969 raise _api.kwarg_error("set_extent", kwargs)
970 xmin = self.axes._validate_converted_limits(
971 xmin, self.convert_xunits)
972 xmax = self.axes._validate_converted_limits(
973 xmax, self.convert_xunits)
974 ymin = self.axes._validate_converted_limits(
975 ymin, self.convert_yunits)
976 ymax = self.axes._validate_converted_limits(
977 ymax, self.convert_yunits)
978 extent = [xmin, xmax, ymin, ymax]
979
980 self._extent = extent
981 corners = (xmin, ymin), (xmax, ymax)
982 self.axes.update_datalim(corners)
983 self.sticky_edges.x[:] = [xmin, xmax]
984 self.sticky_edges.y[:] = [ymin, ymax]
985 if self.axes.get_autoscalex_on():
986 self.axes.set_xlim(xmin, xmax, auto=None)
987 if self.axes.get_autoscaley_on():
988 self.axes.set_ylim(ymin, ymax, auto=None)
989 self.stale = True
990
991 def get_extent(self):
992 """Return the image extent as tuple (left, right, bottom, top)."""

Callers 3

imshowMethod · 0.95
test_extent_unitsFunction · 0.45
test_empty_imshowFunction · 0.45

Calls 5

_process_unit_infoMethod · 0.80
update_datalimMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45

Tested by 2

test_extent_unitsFunction · 0.36
test_empty_imshowFunction · 0.36