@@ -55,15 +55,16 @@ def _annotate(ax, x, y, title):
5555# -----------------------------
5656#
5757# Often, however, data is provided where *X* and *Y* match the shape of *Z*.
58- # As of Matplotlib v3.3, ``shading='flat'`` is deprecated when this is the
59- # case, a warning is raised, and the last row and column of *Z* are dropped.
60- # This dropping of the last row and column is what Matplotlib did silently
61- # previous to v3.3, and is compatible with what Matlab does.
58+ # While this makes sense for other ``shading`` types, it is no longer permitted
59+ # when ``shading='flat'`` (and will raise a MatplotlibDeprecationWarning as of
60+ # Matplotlib v3.3). Historically, Matplotlib silently dropped the last row and
61+ # column of *Z* in this case, to match Matlab's behavior. If this behavior is
62+ # still desired, simply drop the last row and column manually:
6263
6364x = np .arange (ncols ) # note *not* ncols + 1 as before
6465y = np .arange (nrows )
6566fig , ax = plt .subplots ()
66- ax .pcolormesh (x , y , Z , shading = 'flat' , vmin = Z .min (), vmax = Z .max ())
67+ ax .pcolormesh (x , y , Z [: - 1 , : - 1 ] , shading = 'flat' , vmin = Z .min (), vmax = Z .max ())
6768_annotate (ax , x , y , "shading='flat': X, Y, C same shape" )
6869
6970###############################################################################
0 commit comments