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

Class Rectangle

lib/matplotlib/patches.py:826–1044  ·  view source on GitHub ↗

A rectangle defined via an anchor point *xy* and its *width* and *height*. The rectangle extends from ``xy[0]`` to ``xy[0] + width`` in x-direction and from ``xy[1]`` to ``xy[1] + height`` in y-direction. :: : +------------------+ : |

Source from the content-addressed store, hash-verified

824
825
826class Rectangle(Patch):
827 """
828 A rectangle defined via an anchor point *xy* and its *width* and *height*.
829
830 The rectangle extends from ``xy[0]`` to ``xy[0] + width`` in x-direction
831 and from ``xy[1]`` to ``xy[1] + height`` in y-direction. ::
832
833 : +------------------+
834 : | |
835 : height |
836 : | |
837 : (xy)---- width -----+
838
839 One may picture *xy* as the bottom left corner, but which corner *xy* is
840 actually depends on the direction of the axis and the sign of *width*
841 and *height*; e.g. *xy* would be the bottom right corner if the x-axis
842 was inverted or if *width* was negative.
843 """
844
845 def __str__(self):
846 pars = self._x0, self._y0, self._width, self._height, self.angle
847 fmt = "Rectangle(xy=(%g, %g), width=%g, height=%g, angle=%g)"
848 return fmt % pars
849
850 @_docstring.interpd
851 def __init__(self, xy, width, height, *,
852 angle=0.0, rotation_point='xy', **kwargs):
853 """
854 Parameters
855 ----------
856 xy : (float, float)
857 The anchor point.
858 width : float
859 Rectangle width.
860 height : float
861 Rectangle height.
862 angle : float, default: 0
863 Rotation in degrees anti-clockwise about the rotation point.
864 rotation_point : {'xy', 'center', (number, number)}, default: 'xy'
865 If ``'xy'``, rotate around the anchor point. If ``'center'`` rotate
866 around the center. If 2-tuple of number, rotate around this
867 coordinate.
868
869 Other Parameters
870 ----------------
871 **kwargs : `~matplotlib.patches.Patch` properties
872 %(Patch:kwdoc)s
873
874 See Also
875 --------
876 FancyBboxPatch : A rectangle with a fancy box style, e.g. rounded corners.
877 """
878 super().__init__(**kwargs)
879 self._x0 = xy[0]
880 self._y0 = xy[1]
881 self._width = width
882 self._height = height
883 self.angle = float(angle)

Callers 15

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
_create_patchMethod · 0.90
_create_patchMethod · 0.90
create_artistsMethod · 0.90
test_hatching_legendFunction · 0.90
test_corner_centerFunction · 0.90
test_rotate_rectFunction · 0.90
test_rotate_rect_drawFunction · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…