|
21 | 21 | from ..internals import ic # noqa: F401 |
22 | 22 | from ..internals import _not_none, docstring, rcsetup, warnings |
23 | 23 | from ..utils import edges, units |
24 | | -from .plot import ( |
25 | | - _apply_cmap, |
26 | | - _apply_cycle, |
27 | | - _bar_extras, |
28 | | - _barh_extras, |
29 | | - _boxplot_extras, |
30 | | - _fill_between_extras, |
31 | | - _fill_betweenx_extras, |
32 | | - _get_transform, |
33 | | - _hist_extras, |
34 | | - _hlines_extras, |
35 | | - _indicate_error, |
36 | | - _parametric_extras, |
37 | | - _plot_extras, |
38 | | - _scatter_extras, |
39 | | - _standardize_1d, |
40 | | - _standardize_2d, |
41 | | - _stem_extras, |
42 | | - _text_extras, |
43 | | - _violinplot_extras, |
44 | | - _vlines_extras, |
45 | | - colorbar_extras, |
46 | | - legend_extras, |
47 | | -) |
| 24 | +from . import plot as wrap |
48 | 25 |
|
49 | 26 | __all__ = ['Axes'] |
50 | 27 |
|
@@ -1132,7 +1109,7 @@ def inset_axes( |
1132 | 1109 | if not transform: |
1133 | 1110 | transform = self.transAxes |
1134 | 1111 | else: |
1135 | | - transform = _get_transform(self, transform) |
| 1112 | + transform = wrap._get_transform(self, transform) |
1136 | 1113 | label = kwargs.pop('label', 'inset_axes') |
1137 | 1114 | proj = _not_none(proj=proj, projection=projection) |
1138 | 1115 | proj_kw = _not_none(proj_kw=proj_kw, projection_kw=projection_kw, default={}) |
@@ -1273,9 +1250,6 @@ def panel_axes(self, side, **kwargs): |
1273 | 1250 | side = self._loc_translate(side, 'panel') |
1274 | 1251 | return self.figure._add_axes_panel(self, side, **kwargs) |
1275 | 1252 |
|
1276 | | - @_parametric_extras |
1277 | | - @_standardize_1d |
1278 | | - @_apply_cmap |
1279 | 1253 | def parametric( |
1280 | 1254 | self, *args, values=None, |
1281 | 1255 | cmap=None, norm=None, interp=0, |
@@ -1676,7 +1650,7 @@ def colorbar( |
1676 | 1650 | ax, kwargs = self._inset_colorbar_axes(loc=loc, width=width, length=length, pad=pad, **kwargs) # noqa: E501 |
1677 | 1651 |
|
1678 | 1652 | # Generate colorbar |
1679 | | - obj = colorbar_extras(ax, mappable, values, **kwargs) |
| 1653 | + obj = wrap.colorbar_extras(ax, mappable, values, **kwargs) |
1680 | 1654 | self._add_colorbar_legend(loc, obj, legend=False) # possibly replace another |
1681 | 1655 | return obj |
1682 | 1656 |
|
@@ -1782,7 +1756,7 @@ def legend( |
1782 | 1756 | raise ValueError(f'Invalid panel side {side!r}.') |
1783 | 1757 |
|
1784 | 1758 | # Generate legend |
1785 | | - obj = legend_extras(self, handles, labels, loc=loc, **kwargs) |
| 1759 | + obj = wrap.legend_extras(self, handles, labels, loc=loc, **kwargs) |
1786 | 1760 | self._add_colorbar_legend(loc, obj, legend=True) # possibly replace another |
1787 | 1761 | return obj |
1788 | 1762 |
|
@@ -1825,107 +1799,172 @@ def number(self, num): |
1825 | 1799 | raise ValueError(f'Invalid number {num!r}. Must be integer >=1.') |
1826 | 1800 | self._number = num |
1827 | 1801 |
|
1828 | | - # Wrapped by special functions |
1829 | | - # Also support redirecting to Basemap methods |
1830 | | - text = _text_extras( |
1831 | | - maxes.Axes.text |
| 1802 | + # Apply text wrapper |
| 1803 | + text = wrap._apply_wrappers( |
| 1804 | + maxes.Axes.text, |
| 1805 | + wrap.text_extras, |
1832 | 1806 | ) |
1833 | | - plot = _plot_extras(_standardize_1d(_indicate_error(_apply_cycle( |
1834 | | - maxes.Axes.plot |
1835 | | - )))) |
1836 | | - scatter = _scatter_extras(_standardize_1d(_indicate_error(_apply_cycle( |
1837 | | - maxes.Axes.scatter |
1838 | | - )))) |
1839 | | - bar = _bar_extras(_standardize_1d(_indicate_error(_apply_cycle( |
1840 | | - maxes.Axes.bar |
1841 | | - )))) |
1842 | | - barh = _barh_extras( # calls self.bar |
1843 | | - maxes.Axes.barh |
| 1807 | + |
| 1808 | + # Apply 1D plotting command wrappers |
| 1809 | + plot = wrap._apply_wrappers( |
| 1810 | + maxes.Axes.plot, |
| 1811 | + wrap._plot_extras, |
| 1812 | + wrap.standardize_1d, |
| 1813 | + wrap.indicate_error, |
| 1814 | + wrap.apply_cycle, |
| 1815 | + ) |
| 1816 | + scatter = wrap._apply_wrappers( |
| 1817 | + maxes.Axes.scatter, |
| 1818 | + wrap.scatter_extras, |
| 1819 | + wrap.standardize_1d, |
| 1820 | + wrap.indicate_error, |
| 1821 | + wrap.apply_cycle, |
| 1822 | + ) |
| 1823 | + hist = wrap._apply_wrappers( |
| 1824 | + maxes.Axes.hist, |
| 1825 | + wrap._hist_extras, |
| 1826 | + wrap.standardize_1d, |
| 1827 | + wrap.apply_cycle, |
| 1828 | + ) |
| 1829 | + bar = wrap._apply_wrappers( |
| 1830 | + maxes.Axes.bar, |
| 1831 | + wrap.bar_extras, |
| 1832 | + wrap.standardize_1d, |
| 1833 | + wrap.indicate_error, |
| 1834 | + wrap.apply_cycle, |
| 1835 | + ) |
| 1836 | + barh = wrap._apply_wrappers( |
| 1837 | + maxes.Axes.barh, |
| 1838 | + wrap.barh_extras, |
| 1839 | + ) |
| 1840 | + boxplot = wrap._apply_wrappers( |
| 1841 | + maxes.Axes.boxplot, |
| 1842 | + wrap.boxplot_extras, |
| 1843 | + wrap.standardize_1d, |
| 1844 | + wrap.apply_cycle, |
| 1845 | + ) |
| 1846 | + violinplot = wrap._apply_wrappers( |
| 1847 | + maxes.Axes.violinplot, |
| 1848 | + wrap.violinplot_extras, |
| 1849 | + wrap.standardize_1d, |
| 1850 | + wrap.indicate_error, |
| 1851 | + wrap.apply_cycle, |
1844 | 1852 | ) |
1845 | | - hist = _hist_extras(_standardize_1d(_apply_cycle( |
1846 | | - maxes.Axes.hist |
1847 | | - ))) |
1848 | | - boxplot = _boxplot_extras(_standardize_1d(_apply_cycle( |
1849 | | - maxes.Axes.boxplot |
1850 | | - ))) |
1851 | | - violinplot = _violinplot_extras(_standardize_1d(_indicate_error(_apply_cycle( |
1852 | | - maxes.Axes.violinplot |
1853 | | - )))) |
1854 | | - fill_between = _fill_between_extras(_standardize_1d(_apply_cycle( |
1855 | | - maxes.Axes.fill_between |
1856 | | - ))) |
1857 | | - fill_betweenx = _fill_betweenx_extras(_standardize_1d(_apply_cycle( |
1858 | | - maxes.Axes.fill_betweenx |
1859 | | - ))) |
1860 | | - |
1861 | | - # Wrapped by cycle wrapper and standardized |
1862 | | - pie = _standardize_1d(_apply_cycle( |
1863 | | - maxes.Axes.pie |
1864 | | - )) |
1865 | | - step = _standardize_1d(_apply_cycle( |
1866 | | - maxes.Axes.step |
1867 | | - )) |
1868 | | - |
1869 | | - # Wrapped by standardizer |
1870 | | - stem = _standardize_1d(_stem_extras( |
1871 | | - maxes.Axes.stem |
1872 | | - )) |
1873 | | - hlines = _standardize_1d(_hlines_extras( |
1874 | | - maxes.Axes.hlines |
1875 | | - )) |
1876 | | - vlines = _standardize_1d(_vlines_extras( |
1877 | | - maxes.Axes.vlines |
1878 | | - )) |
1879 | | - |
1880 | | - # Wrapped by cmap wrapper and standardized |
1881 | | - # Also support redirecting to Basemap methods |
1882 | | - hexbin = _standardize_1d(_apply_cmap( |
1883 | | - maxes.Axes.hexbin |
1884 | | - )) |
1885 | | - contour = _standardize_2d(_apply_cmap( |
1886 | | - maxes.Axes.contour |
1887 | | - )) |
1888 | | - contourf = _standardize_2d(_apply_cmap( |
1889 | | - maxes.Axes.contourf |
1890 | | - )) |
1891 | | - pcolor = _standardize_2d(_apply_cmap( |
1892 | | - maxes.Axes.pcolor |
1893 | | - )) |
1894 | | - pcolormesh = _standardize_2d(_apply_cmap( |
1895 | | - maxes.Axes.pcolormesh |
1896 | | - )) |
1897 | | - pcolorfast = _standardize_2d(_apply_cmap( |
1898 | | - maxes.Axes.pcolorfast # WARNING: not available in cartopy and basemap |
1899 | | - )) |
1900 | | - streamplot = _standardize_2d(_apply_cmap( |
1901 | | - maxes.Axes.streamplot |
1902 | | - )) |
1903 | | - quiver = _standardize_2d(_apply_cmap( |
1904 | | - maxes.Axes.quiver |
1905 | | - )) |
1906 | | - barbs = _standardize_2d(_apply_cmap( |
1907 | | - maxes.Axes.barbs |
1908 | | - )) |
1909 | | - imshow = _apply_cmap( |
1910 | | - maxes.Axes.imshow |
| 1853 | + fill_between = wrap._apply_wrappers( |
| 1854 | + maxes.Axes.fill_between, |
| 1855 | + wrap.fill_between_extras, |
| 1856 | + wrap.standardize_1d, |
| 1857 | + wrap.apply_cycle, |
1911 | 1858 | ) |
| 1859 | + fill_betweenx = wrap._apply_wrappers( |
| 1860 | + maxes.Axes.fill_betweenx, |
| 1861 | + wrap.fill_betweenx_extras, |
| 1862 | + wrap.standardize_1d, |
| 1863 | + wrap.apply_cycle, |
| 1864 | + ) |
| 1865 | + pie = wrap._apply_wrappers( |
| 1866 | + maxes.Axes.pie, |
| 1867 | + wrap.standardize_1d, |
| 1868 | + wrap.apply_cycle, |
1912 | 1869 |
|
1913 | | - # Wrapped only by cmap wrapper |
1914 | | - tripcolor = _apply_cmap( |
1915 | | - maxes.Axes.tripcolor |
1916 | 1870 | ) |
1917 | | - tricontour = _apply_cmap( |
1918 | | - maxes.Axes.tricontour |
| 1871 | + step = wrap._apply_wrappers( |
| 1872 | + maxes.Axes.step, |
| 1873 | + wrap.standardize_1d, |
| 1874 | + wrap.apply_cycle, |
| 1875 | + ) |
| 1876 | + stem = wrap._apply_wrappers( |
| 1877 | + maxes.Axes.stem, |
| 1878 | + wrap._stem_extras, # TODO check this |
| 1879 | + wrap.standardize_1d, |
| 1880 | + ) |
| 1881 | + hlines = wrap._apply_wrappers( |
| 1882 | + maxes.Axes.hlines, |
| 1883 | + wrap.hlines_extras, # TODO check this |
| 1884 | + wrap.standardize_1d, |
| 1885 | + ) |
| 1886 | + vlines = wrap._apply_wrappers( |
| 1887 | + maxes.Axes.vlines, |
| 1888 | + wrap.vlines_extras, # TODO check this |
| 1889 | + wrap.standardize_1d, |
| 1890 | + ) |
| 1891 | + parametric = wrap._apply_wrappers( |
| 1892 | + parametric, |
| 1893 | + wrap._parametric_extras, |
| 1894 | + wrap.standardize_1d, |
| 1895 | + wrap.apply_cmap, |
| 1896 | + ) |
| 1897 | + hexbin = wrap._apply_wrappers( |
| 1898 | + wrap.standardize_1d, |
| 1899 | + wrap.apply_cmap, |
| 1900 | + ) |
| 1901 | + |
| 1902 | + # Apply 2D plotting command wrappers |
| 1903 | + contour = wrap._apply_wrappers( |
| 1904 | + maxes.Axes.contour, |
| 1905 | + wrap.standardize_2d, |
| 1906 | + wrap.apply_cmap, |
| 1907 | + ) |
| 1908 | + contourf = wrap._apply_wrappers( |
| 1909 | + maxes.Axes.contourf, |
| 1910 | + wrap.standardize_2d, |
| 1911 | + wrap.apply_cmap, |
| 1912 | + ) |
| 1913 | + pcolor = wrap._apply_wrappers( |
| 1914 | + maxes.Axes.pcolor, |
| 1915 | + wrap.standardize_2d, |
| 1916 | + wrap.apply_cmap, |
| 1917 | + ) |
| 1918 | + pcolormesh = wrap._apply_wrappers( |
| 1919 | + maxes.Axes.pcolormesh, |
| 1920 | + wrap.standardize_2d, |
| 1921 | + wrap.apply_cmap, |
| 1922 | + ) |
| 1923 | + pcolorfast = wrap._apply_wrappers( |
| 1924 | + maxes.Axes.pcolorfast, # WARNING: not available in cartopy and basemap |
| 1925 | + wrap.standardize_2d, |
| 1926 | + wrap.apply_cmap, |
| 1927 | + ) |
| 1928 | + streamplot = wrap._apply_wrappers( |
| 1929 | + maxes.Axes.streamplot, |
| 1930 | + wrap.standardize_2d, |
| 1931 | + wrap.apply_cmap, |
| 1932 | + ) |
| 1933 | + quiver = wrap._apply_wrappers( |
| 1934 | + maxes.Axes.quiver, |
| 1935 | + wrap.standardize_2d, |
| 1936 | + wrap.apply_cmap, |
| 1937 | + ) |
| 1938 | + barbs = wrap._apply_wrappers( |
| 1939 | + maxes.Axes.barbs, |
| 1940 | + wrap.standardize_2d, |
| 1941 | + wrap.apply_cmap, |
| 1942 | + ) |
| 1943 | + tripcolor = wrap._apply_wrappers( |
| 1944 | + maxes.Axes.tripcolor, |
| 1945 | + wrap.apply_cmap, |
| 1946 | + ) |
| 1947 | + tricontour = wrap._apply_wrappers( |
| 1948 | + maxes.Axes.tricontour, |
| 1949 | + wrap.apply_cmap, |
| 1950 | + ) |
| 1951 | + tricontourf = wrap._apply_wrappers( |
| 1952 | + maxes.Axes.tricontourf, |
| 1953 | + wrap.apply_cmap, |
1919 | 1954 | ) |
1920 | | - tricontourf = _apply_cmap( |
1921 | | - maxes.Axes.tricontourf |
| 1955 | + hist2d = wrap._apply_wrappers( |
| 1956 | + maxes.Axes.hist2d, |
| 1957 | + wrap.apply_cmap, |
1922 | 1958 | ) |
1923 | | - hist2d = _apply_cmap( |
1924 | | - maxes.Axes.hist2d |
| 1959 | + spy = wrap._apply_wrappers( |
| 1960 | + maxes.Axes.spy, |
| 1961 | + wrap.apply_cmap, |
1925 | 1962 | ) |
1926 | | - spy = _apply_cmap( |
1927 | | - maxes.Axes.spy |
| 1963 | + imshow = wrap._apply_wrappers( |
| 1964 | + maxes.Axes.imshow, |
| 1965 | + wrap.apply_cmap, |
1928 | 1966 | ) |
1929 | | - matshow = _apply_cmap( |
1930 | | - maxes.Axes.matshow |
| 1967 | + matshow = wrap._apply_wrappers( |
| 1968 | + maxes.Axes.matshow, |
| 1969 | + wrap.apply_cmap, |
1931 | 1970 | ) |
0 commit comments