|
38 | 38 | from cartopy import config |
39 | 39 | import cartopy.crs as ccrs |
40 | 40 | import cartopy.feature |
41 | | -from cartopy.mpl import _MPL_38 |
42 | 41 | import cartopy.mpl.contour |
43 | 42 | import cartopy.mpl.feature_artist as feature_artist |
44 | 43 | import cartopy.mpl.geocollection |
@@ -1592,21 +1591,12 @@ def contour(self, *args, **kwargs): |
1592 | 1591 | """ |
1593 | 1592 | result = super().contour(*args, **kwargs) |
1594 | 1593 |
|
1595 | | - if not _MPL_38: |
1596 | | - # We need to compute the dataLim correctly for contours. |
1597 | | - bboxes = [col.get_datalim(self.transData) |
1598 | | - for col in result.collections |
1599 | | - if col.get_paths()] |
1600 | | - if bboxes: |
1601 | | - extent = mtransforms.Bbox.union(bboxes) |
1602 | | - self.update_datalim(extent.get_points()) |
1603 | | - else: |
1604 | | - # We need to compute the dataLim correctly for contours and set the |
1605 | | - # artist's sticky edges to match. |
1606 | | - datalim = result.get_datalim(self.transData) |
1607 | | - self.update_datalim(datalim) |
1608 | | - result.sticky_edges.x[:] = datalim.xmin, datalim.xmax |
1609 | | - result.sticky_edges.y[:] = datalim.ymin, datalim.ymax |
| 1594 | + # We need to compute the dataLim correctly for contours and set the |
| 1595 | + # artist's sticky edges to match. |
| 1596 | + datalim = result.get_datalim(self.transData) |
| 1597 | + self.update_datalim(datalim) |
| 1598 | + result.sticky_edges.x[:] = datalim.xmin, datalim.xmax |
| 1599 | + result.sticky_edges.y[:] = datalim.ymin, datalim.ymax |
1610 | 1600 |
|
1611 | 1601 | self.autoscale_view() |
1612 | 1602 |
|
@@ -1638,21 +1628,12 @@ def contourf(self, *args, **kwargs): |
1638 | 1628 | """ |
1639 | 1629 | result = super().contourf(*args, **kwargs) |
1640 | 1630 |
|
1641 | | - if not _MPL_38: |
1642 | | - # We need to compute the dataLim correctly for contours. |
1643 | | - bboxes = [col.get_datalim(self.transData) |
1644 | | - for col in result.collections |
1645 | | - if col.get_paths()] |
1646 | | - if bboxes: |
1647 | | - extent = mtransforms.Bbox.union(bboxes) |
1648 | | - self.update_datalim(extent.get_points()) |
1649 | | - else: |
1650 | | - # We need to compute the dataLim correctly for contours and set the |
1651 | | - # artist's sticky edges to match. |
1652 | | - datalim = result.get_datalim(self.transData) |
1653 | | - self.update_datalim(datalim) |
1654 | | - result.sticky_edges.x[:] = datalim.xmin, datalim.xmax |
1655 | | - result.sticky_edges.y[:] = datalim.ymin, datalim.ymax |
| 1631 | + # We need to compute the dataLim correctly for contours and set the |
| 1632 | + # artist's sticky edges to match. |
| 1633 | + datalim = result.get_datalim(self.transData) |
| 1634 | + self.update_datalim(datalim) |
| 1635 | + result.sticky_edges.x[:] = datalim.xmin, datalim.xmax |
| 1636 | + result.sticky_edges.y[:] = datalim.ymin, datalim.ymax |
1656 | 1637 |
|
1657 | 1638 | self.autoscale_view() |
1658 | 1639 |
|
@@ -1936,36 +1917,19 @@ def _wrap_quadmesh(self, collection, **kwargs): |
1936 | 1917 | vmax = kwargs.pop('vmax', None) |
1937 | 1918 | norm = kwargs.pop('norm', None) |
1938 | 1919 | cmap = kwargs.pop('cmap', None) |
| 1920 | + |
1939 | 1921 | # Plot all of the wrapped cells. |
1940 | 1922 | # `pcolor` only draws polygons where the data is not |
1941 | 1923 | # masked, so this will only draw a limited subset of |
1942 | 1924 | # polygons that were actually wrapped. |
1943 | | - |
1944 | | - if not _MPL_38: |
1945 | | - # We will add the original data mask in later to |
1946 | | - # make sure that set_array can work in future |
1947 | | - # calls on the proper sized array inputs. |
1948 | | - # NOTE: we don't use C.data here because C.data could |
1949 | | - # contain nan's which would be masked in the |
1950 | | - # pcolor routines, which we don't want. We will |
1951 | | - # fill in the proper data later with set_array() |
1952 | | - # calls. |
1953 | | - pcolor_zeros = np.ma.array(np.zeros(C.shape), mask=pcolor_mask) |
1954 | | - pcolor_col = self.pcolor(coords[..., 0], coords[..., 1], |
1955 | | - pcolor_zeros, zorder=zorder, |
1956 | | - **kwargs) |
1957 | | - |
1958 | | - # The pcolor_col is now possibly shorter than the |
1959 | | - # actual collection, so grab the masked cells |
1960 | | - pcolor_col.set_array(pcolor_data[mask].ravel()) |
1961 | | - else: |
1962 | | - pcolor_col = self.pcolor(coords[..., 0], coords[..., 1], |
1963 | | - pcolor_data, zorder=zorder, |
1964 | | - **kwargs) |
1965 | | - # Currently pcolor_col.get_array() will return a compressed array |
1966 | | - # and warn unless we explicitly set the 2D array. This should be |
1967 | | - # unnecessary with future matplotlib versions. |
1968 | | - pcolor_col.set_array(pcolor_data) |
| 1925 | + pcolor_col = self.pcolor(coords[..., 0], coords[..., 1], |
| 1926 | + pcolor_data, zorder=zorder, |
| 1927 | + **kwargs) |
| 1928 | + |
| 1929 | + # In matplotlib v3.8 and v3.9 pcolor_col.get_array() will return a |
| 1930 | + # compressed array and warn unless we explicitly set the 2D array. |
| 1931 | + # This can be removed when we support only matplotlib v3.10+. |
| 1932 | + pcolor_col.set_array(pcolor_data) |
1969 | 1933 |
|
1970 | 1934 | pcolor_col.set_cmap(cmap) |
1971 | 1935 | pcolor_col.set_norm(norm) |
|
0 commit comments