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

Method set_clip_path

lib/matplotlib/artist.py:826–886  ·  view source on GitHub ↗

Set the artist's clip path. Parameters ---------- path : `~matplotlib.patches.Patch` or `.Path` or `.TransformedPath` or None The clip path. If given a `.Path`, *transform* must be provided as well. If *None*, a previously set clip path is re

(self, path, transform=None)

Source from the content-addressed store, hash-verified

824 self.stale = True
825
826 def set_clip_path(self, path, transform=None):
827 """
828 Set the artist's clip path.
829
830 Parameters
831 ----------
832 path : `~matplotlib.patches.Patch` or `.Path` or `.TransformedPath` or None
833 The clip path. If given a `.Path`, *transform* must be provided as
834 well. If *None*, a previously set clip path is removed.
835 transform : `~matplotlib.transforms.Transform`, optional
836 Only used if *path* is a `.Path`, in which case the given `.Path`
837 is converted to a `.TransformedPath` using *transform*.
838
839 Notes
840 -----
841 For efficiency, if *path* is a `.Rectangle` this method will set the
842 clipping box to the corresponding rectangle and set the clipping path
843 to ``None``.
844
845 For technical reasons (support of `~.Artist.set`), a tuple
846 (*path*, *transform*) is also accepted as a single positional
847 parameter.
848
849 .. ACCEPTS: Patch or (Path, Transform) or None
850 """
851 from matplotlib.patches import Patch, Rectangle
852
853 success = False
854 if transform is None:
855 if isinstance(path, Rectangle):
856 self.clipbox = TransformedBbox(Bbox.unit(),
857 path.get_transform())
858 self._clippath = None
859 success = True
860 elif isinstance(path, Patch):
861 self._clippath = TransformedPatchPath(path)
862 success = True
863 elif isinstance(path, tuple):
864 path, transform = path
865
866 if path is None:
867 self._clippath = None
868 success = True
869 elif isinstance(path, Path):
870 self._clippath = TransformedPath(path, transform)
871 success = True
872 elif isinstance(path, TransformedPatchPath):
873 self._clippath = path
874 success = True
875 elif isinstance(path, TransformedPath):
876 self._clippath = path
877 success = True
878
879 if not success:
880 raise TypeError(
881 "Invalid arguments to set_clip_path, of type "
882 f"{type(path).__name__} and {type(transform).__name__}")
883 # This may result in the callbacks being hit twice, but guarantees they

Callers 1

_set_gc_clipMethod · 0.45

Calls 6

pchangedMethod · 0.95
TransformedBboxClass · 0.85
TransformedPathClass · 0.85
unitMethod · 0.80
get_transformMethod · 0.45

Tested by

no test coverage detected