Make a twinx Axes of self. This is used for twinx and twiny.
(self, *args, delta_zorder=0.0, **kwargs)
| 4792 | patch.set_visible((ax is bottom) and ax.get_frame_on()) |
| 4793 | |
| 4794 | def _make_twin_axes(self, *args, delta_zorder=0.0, **kwargs): |
| 4795 | """Make a twinx Axes of self. This is used for twinx and twiny.""" |
| 4796 | if 'sharex' in kwargs and 'sharey' in kwargs: |
| 4797 | # The following line is added in v2.2 to avoid breaking Seaborn, |
| 4798 | # which currently uses this internal API. |
| 4799 | if kwargs["sharex"] is not self and kwargs["sharey"] is not self: |
| 4800 | raise ValueError("Twinned Axes may share only one axis") |
| 4801 | ss = self.get_subplotspec() |
| 4802 | if ss: |
| 4803 | twin = self.get_figure(root=False).add_subplot(ss, *args, **kwargs) |
| 4804 | else: |
| 4805 | twin = self.get_figure(root=False).add_axes( |
| 4806 | self.get_position(True), *args, **kwargs, |
| 4807 | axes_locator=_TransformedBoundsLocator( |
| 4808 | [0, 0, 1, 1], self.transAxes)) |
| 4809 | self.set_adjustable('datalim') |
| 4810 | twin.set_adjustable('datalim') |
| 4811 | twin.set_zorder(self.get_zorder() + delta_zorder) |
| 4812 | |
| 4813 | self._twinned_axes.join(self, twin) |
| 4814 | |
| 4815 | # If the parent Axes has been manually positioned (set_position() sets |
| 4816 | # in_layout=False), the SubplotSpec-based add_subplot(...) path ignores |
| 4817 | # that manual position when creating a twin. In that case, explicitly |
| 4818 | # copy both the original and active positions to the twin so they start |
| 4819 | # aligned. |
| 4820 | # |
| 4821 | # For layout-managed Axes (in_layout=True), we keep the existing |
| 4822 | # SubplotSpec-driven behavior, so layout engines such as tight_layout |
| 4823 | # and constrained_layout continue to control positioning. |
| 4824 | if not self.get_in_layout(): |
| 4825 | twin._set_position(self.get_position(original=True), which="original") |
| 4826 | twin._set_position(self.get_position(original=False), which="active") |
| 4827 | |
| 4828 | self._update_twinned_axes_patch_visibility() |
| 4829 | return twin |
| 4830 | |
| 4831 | def twinx(self, axes_class=None, *, delta_zorder=0.0, **kwargs): |
| 4832 | """ |
no test coverage detected