Set how the Axes adjusts to achieve the required aspect ratio. Parameters ---------- adjustable : {'box', 'datalim'} If 'box', change the physical dimensions of the Axes. If 'datalim', change the ``x`` or ``y`` data limits. This m
(self, adjustable, share=False)
| 1786 | return self._adjustable |
| 1787 | |
| 1788 | def set_adjustable(self, adjustable, share=False): |
| 1789 | """ |
| 1790 | Set how the Axes adjusts to achieve the required aspect ratio. |
| 1791 | |
| 1792 | Parameters |
| 1793 | ---------- |
| 1794 | adjustable : {'box', 'datalim'} |
| 1795 | If 'box', change the physical dimensions of the Axes. |
| 1796 | If 'datalim', change the ``x`` or ``y`` data limits. This |
| 1797 | may ignore explicitly defined axis limits. |
| 1798 | |
| 1799 | share : bool, default: False |
| 1800 | If ``True``, apply the settings to all shared Axes. |
| 1801 | |
| 1802 | See Also |
| 1803 | -------- |
| 1804 | matplotlib.axes.Axes.get_adjustable |
| 1805 | Return the current value of *adjustable*. |
| 1806 | matplotlib.axes.Axes.set_aspect |
| 1807 | For a description of aspect handling. |
| 1808 | |
| 1809 | Notes |
| 1810 | ----- |
| 1811 | Shared Axes (of which twinned Axes are a special case) |
| 1812 | impose restrictions on how aspect ratios can be imposed. |
| 1813 | For twinned Axes, use 'datalim'. For Axes that share both |
| 1814 | x and y, use 'box'. Otherwise, either 'datalim' or 'box' |
| 1815 | may be used. These limitations are partly a requirement |
| 1816 | to avoid over-specification, and partly a result of the |
| 1817 | particular implementation we are currently using, in |
| 1818 | which the adjustments for aspect ratios are done sequentially |
| 1819 | and independently on each Axes as it is drawn. |
| 1820 | """ |
| 1821 | _api.check_in_list(["box", "datalim"], adjustable=adjustable) |
| 1822 | if share: |
| 1823 | axs = {sibling for name in self._axis_names |
| 1824 | for sibling in self._shared_axes[name].get_siblings(self)} |
| 1825 | else: |
| 1826 | axs = [self] |
| 1827 | if (adjustable == "datalim" |
| 1828 | and any(getattr(ax.get_data_ratio, "__func__", None) |
| 1829 | != _AxesBase.get_data_ratio |
| 1830 | for ax in axs)): |
| 1831 | # Limits adjustment by apply_aspect assumes that the axes' aspect |
| 1832 | # ratio can be computed from the data limits and scales. |
| 1833 | raise ValueError("Cannot set Axes adjustable to 'datalim' for " |
| 1834 | "Axes which override 'get_data_ratio'") |
| 1835 | for ax in axs: |
| 1836 | ax._adjustable = adjustable |
| 1837 | ax.stale = True |
| 1838 | |
| 1839 | def get_box_aspect(self): |
| 1840 | """ |