Set the `.Figure` or `.SubFigure` instance the artist belongs to. .. warning:: This function should typically not be called by users. This is a low-level API and only modifies the internal state of the Artist. Only modifying this is not enough
(self, fig)
| 765 | return self._parent_figure |
| 766 | |
| 767 | def set_figure(self, fig): |
| 768 | """ |
| 769 | Set the `.Figure` or `.SubFigure` instance the artist belongs to. |
| 770 | |
| 771 | .. warning:: |
| 772 | |
| 773 | This function should typically not be called by users. |
| 774 | |
| 775 | This is a low-level API and only modifies the internal state of the |
| 776 | Artist. Only modifying this is not enough and will typically lead |
| 777 | to an inconsistent state, because the state of the figure has to |
| 778 | be changed as well. |
| 779 | |
| 780 | Users should typically instead call one of the high-level APIs, i.e. |
| 781 | `.Figure.add_artist` or one of the Axes methods |
| 782 | :ref:`axes-api-adding-artists`. |
| 783 | |
| 784 | Parameters |
| 785 | ---------- |
| 786 | fig : `~matplotlib.figure.Figure` or `~matplotlib.figure.SubFigure` |
| 787 | """ |
| 788 | # if this is a no-op just return |
| 789 | if self._parent_figure is fig: |
| 790 | return |
| 791 | # if we currently have a figure (the case of both `self.figure` |
| 792 | # and *fig* being none is taken care of above) we then user is |
| 793 | # trying to change the figure an artist is associated with which |
| 794 | # is not allowed for the same reason as adding the same instance |
| 795 | # to more than one Axes |
| 796 | if self._parent_figure is not None: |
| 797 | raise RuntimeError("Can not put single artist in " |
| 798 | "more than one figure") |
| 799 | self._parent_figure = fig |
| 800 | if self._parent_figure and self._parent_figure is not self: |
| 801 | self.pchanged() |
| 802 | self.stale = True |
| 803 | |
| 804 | figure = property(get_figure, set_figure, |
| 805 | doc=("The (Sub)Figure that the artist is on. For more " |