Repository: SciTools/cartopy

Issue:
pcolormesh does not support RGB(A) arrays
### Description

Since matplotlib version 3.7 `pcolormesh` supports passing (M, N, 3) and (M, N, 4) values to produce RGB(A) images. But using that functionality with cartopy results in error.

#### Code to reproduce

This code without cartopy produces an image:

```
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 40, 161)
y = np.linspace(0, 40, 161)

rgb = np.random.rand(161, 161, 3)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.pcolormesh(x, y, rgb)

plt.show()
```

![image](https://user-images.githubusercontent.com/22771850/224695460-9c50df00-7d8d-40cc-8b08-078d620c98b2.png)

But if cartopy is used, the error appears:

```
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 40, 161)
y = np.linspace(0, 40, 161)

rgb = np.random.rand(161, 161, 3)

fig = plt.figure()
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
ax.pcolormesh(x, y, rgb, transform=ccrs.PlateCarree())

plt.show()
```

#### Traceback

```
Traceback (most recent call last):
  File "/home/user/dev/python/meteosat/minimal.py", line 12, in <module>
    ax.pcolormesh(x, y, rgb, transform=ccrs.PlateCarree())
  File "/home/user/mambaforge/envs/plotter/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py", line 318, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/mambaforge/envs/plotter/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py", line 1784, in pcolormesh
    args, kwargs = self._wrap_args(*args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/mambaforge/envs/plotter/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py", line 1813, in _wrap_args
    nrows, ncols = np.asanyarray(args[2]).shape
    ^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)
```

<details>
 <summary>Full environment definition</summary>

### Operating system

Ubuntu 22.04

### Cartopy version

0.21.1

### conda list

```
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
alsa-lib                  1.2.8                h166bdaf_0    conda-forge
attr                      2.5.1                h166bdaf_1    conda-forge
attrs                     22.2.0             pyh71513ae_0    conda-forge
black                     23.1.0          py311h38be061_0    conda-forge
brotli                    1.0.9                h166bdaf_8    conda-forge
brotli-bin                1.0.9                h166bdaf_8    conda-forge
brotlipy                  0.7.0           py311hd4cff14_1005    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.18.1               h7f98852_0    conda-forge
ca-certificates           2022.12.7            ha878542_0    conda-forge
cairo                     1.16.0            ha61ee94_1014    conda-forge
cartopy                   0.21.1          py311h5d490e5_0    conda-forge
certifi                   2022.12.7          pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py311h409f033_3    conda-forge
cfgrib                    0.9.10.3           pyhd8ed1ab_0    conda-forge
cftime                    1.6.2           py311h4c7f6c3_1    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
click                     8.1.3           unix_pyhd8ed1ab_2    conda-forge
contourpy                 1.0.7           py311ha3edf6b_0    conda-forge
cryptography              39.0.2          py311h9b4c7bb_0    conda-forge
curl                      7.88.1               hdc1c0ab_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
eccodes                   2.28.0               h54fcba4_2    conda-forge
expat                     2.5.0                h27087fc_0    conda-forge
fftw                      3.3.10          nompi_hf0379b8_106    conda-forge
findlibs                  0.0.2              pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.2               h14ed4e7_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.39.0          py311h2582759_0    conda-forge
freeglut                  3.2.2                h9c3ff4c_1    conda-forge
freetype                  2.12.1               hca18f0e_1    conda-forge
geos                      3.11.1               h27087fc_0    conda-forge
gettext                   0.21.1               h27087fc_0    conda-forge
glib                      2.74.1               h6239696_1    conda-forge
glib-tools                2.74.1               h6239696_1    conda-forge
graphite2                 1.3.13            h58526e2_1001    conda-forge
gst-plugins-base          1.22.0               h4243ec0_2    conda-forge
gstreamer                 1.22.0               h25f0c4b_2    conda-forge
gstreamer-orc             0.4.33               h166bdaf_0    conda-forge
harfbuzz                  6.0.0                h8e241bc_0    conda-forge
hdf4                      4.2.15               h9772cbc_5    conda-forge
hdf5                      1.12.2          nompi_h4df4325_101    conda-forge
icu                       70.1                 h27087fc_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
jack                      1.9.22               h11f4161_0    conda-forge
jasper                    2.0.33               h0ff4b12_1    conda-forge
jpeg                      9e                   h0b41bf4_3    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
kiwisolver                1.4.4           py311h4dd048b_1    conda-forge
krb5                      1.20.1               h81ceb04_0    conda-forge
lame                      3.100             h166bdaf_1003    conda-forge
lcms2                     2.15                 hfd0df8a_0    conda-forge
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libaec                    1.0.6                hcb278e6_1    conda-forge
libblas                   3.9.0           16_linux64_openblas    conda-forge
libbrotlicommon           1.0.9                h166bdaf_8    conda-forge
libbrotlidec              1.0.9                h166bdaf_8    conda-forge
libbrotlienc              1.0.9                h166bdaf_8    conda-forge
libcap                    2.66                 ha37c62d_0    conda-forge
libcblas                  3.9.0           16_linux64_openblas    conda-forge
libclang                  15.0.7          default_had23c3d_1    conda-forge
libclang13                15.0.7          default_h3e3d535_1    conda-forge
libcups                   2.3.3                h36d4200_3    conda-forge
libcurl                   7.88.1               hdc1c0ab_0    conda-forge
libdb                     6.2.32               h9c3ff4c_0    conda-forge
libdeflate                1.17                 h0b41bf4_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.10               h28343ad_4    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libflac                   1.4.2                h27087fc_0    conda-forge
libgcc-ng                 12.2.0              h65d4601_19    conda-forge
libgcrypt                 1.10.1               h166bdaf_0    conda-forge
libgfortran-ng            12.2.0              h69a702a_19    conda-forge
libgfortran5              12.2.0              h337968e_19    conda-forge
libglib                   2.74.1               h606061b_1    conda-forge
libglu                    9.0.0             he1b5a44_1001    conda-forge
libgomp                   12.2.0              h65d4601_19    conda-forge
libgpg-error              1.46                 h620e276_0    conda-forge
libiconv                  1.17                 h166bdaf_0    conda-forge
liblapack                 3.9.0           16_linux64_openblas    conda-forge
libllvm15                 15.0.7               hadd5161_0    conda-forge
libnetcdf                 4.9.1           nompi_h34a3ff0_101    conda-forge
libnghttp2                1.52.0               h61bc06f_0    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libogg                    1.3.4                h7f98852_1    conda-forge
libopenblas               0.3.21          pthreads_h78a6416_3    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpng                    1.6.39               h753d276_0    conda-forge
libpq                     15.2                 hb675445_0    conda-forge
libsndfile                1.2.0                hb75c966_0    conda-forge
libsqlite                 3.40.0               h753d276_0    conda-forge
libssh2                   1.10.0               hf14f497_3    conda-forge
libstdcxx-ng              12.2.0              h46fd767_19    conda-forge
libsystemd0               252                  h2a991cd_0    conda-forge
libtiff                   4.5.0                h6adf6a1_2    conda-forge
libtool                   2.4.7                h27087fc_0    conda-forge
libudev1                  253                  h0b41bf4_0    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libwebp-base              1.2.4                h166bdaf_0    conda-forge
libxcb                    1.13              h7f98852_1004    conda-forge
libxkbcommon              1.5.0                h79f4944_0    conda-forge
libxml2                   2.10.3               h7463322_0    conda-forge
libzip                    1.9.2                hc929e4a_1    conda-forge
libzlib                   1.2.13               h166bdaf_4    conda-forge
lz4-c                     1.9.4                hcb278e6_0    conda-forge
matplotlib                3.7.1           py311h38be061_0    conda-forge
matplotlib-base           3.7.1           py311h8597a09_0    conda-forge
mpg123                    1.31.2               hcb278e6_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
mypy_extensions           1.0.0              pyha770c72_0    conda-forge
mysql-common              8.0.32               ha901b37_0    conda-forge
mysql-libs                8.0.32               hd7da12d_0    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
netcdf4                   1.6.3           nompi_py311ha396515_100    conda-forge
nspr                      4.35                 h27087fc_0    conda-forge
nss                       3.88                 he45b914_0    conda-forge
numpy                     1.24.2          py311h8e6699e_0    conda-forge
openjpeg                  2.5.0                hfec8fc6_2    conda-forge
openssl                   3.0.8                h0b41bf4_0    conda-forge
packaging                 23.0               pyhd8ed1ab_0    conda-forge
pandas                    1.5.3           py311h2872171_0    conda-forge
pathspec                  0.11.0             pyhd8ed1ab_0    conda-forge
pcre2                     10.40                hc3806b6_0    conda-forge
pillow                    9.4.0           py311h50def17_1    conda-forge
pip                       23.0.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h36c2ea0_0    conda-forge
platformdirs              3.1.0              pyhd8ed1ab_0    conda-forge
ply                       3.11                       py_1    conda-forge
pooch                     1.7.0              pyhd8ed1ab_0    conda-forge
proj                      9.1.1                h8ffa02c_2    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pulseaudio                16.1                 ha8d29e2_1    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pyopenssl                 23.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyproj                    3.4.1           py311h945b3ca_1    conda-forge
pyqt                      5.15.7          py311ha74522f_3    conda-forge
pyqt5-sip                 12.11.0         py311hcafe171_3    conda-forge
pyshp                     2.3.1              pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.11.0          he550d4f_1_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-eccodes            1.5.1           py311hcb2cf0a_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pytz                      2022.7.1           pyhd8ed1ab_0    conda-forge
qt-main                   5.15.8               h5d23da1_6    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
requests                  2.28.2             pyhd8ed1ab_0    conda-forge
scipy                     1.10.1          py311h8e6699e_0    conda-forge
setuptools                67.6.0             pyhd8ed1ab_0    conda-forge
shapely                   2.0.1           py311h0f577a2_0    conda-forge
sip                       6.7.7           py311hcafe171_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sqlite                    3.40.0               h4ff8645_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tornado                   6.2             py311hd4cff14_1    conda-forge
typing-extensions         4.4.0                hd8ed1ab_0    conda-forge
typing_extensions         4.4.0              pyha770c72_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
urllib3                   1.26.14            pyhd8ed1ab_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xarray                    2023.2.0           pyhd8ed1ab_0    conda-forge
xcb-util                  0.4.0                h166bdaf_0    conda-forge
xcb-util-image            0.4.0                h166bdaf_0    conda-forge
xcb-util-keysyms          0.4.0                h166bdaf_0    conda-forge
xcb-util-renderutil       0.3.9                h166bdaf_0    conda-forge
xcb-util-wm               0.4.1                h166bdaf_0    conda-forge
xorg-fixesproto           5.0               h7f98852_1002    conda-forge
xorg-inputproto           2.3.2             h7f98852_1002    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.0.10               h7f98852_0    conda-forge
xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
xorg-libx11               1.8.4                h0b41bf4_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h0b41bf4_2    conda-forge
xorg-libxfixes            5.0.3             h7f98852_1004    conda-forge
xorg-libxi                1.7.10               h7f98852_0    conda-forge
xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
zlib                      1.2.13               h166bdaf_4    conda-forge
zstd                      1.5.2                h3eb15da_6    conda-forge
```

</details>

`pcolormesh.set_array(None)` not longer works?
### Description
The code from this question: https://stackoverflow.com/questions/48566732/plot-rgb-using-cartopy-pcolormesh (but also my minimal example below) no longer works. More specifically, the line `pcol.set_array(None)` gives an error `AttributeError: 'NoneType' object has no attribute 'ndim'`. The `.set_array(None)` works fine in my environment on a normal `pcolormesh`, when I'm not using Cartopy.

#### Code to reproduce

    import numpy as np
    import matplotlib.pyplot as pl
    import cartopy
    import cartopy.crs as ccrs

    bbox = [3.5, 6.5, 51.45, 52.65]
    lon = np.linspace(3.5, 6.5, 100)
    lat = np.linspace(51.45, 52.65, 100)
    
    r, g = np.meshgrid(np.linspace(0,255,100),np.linspace(0,255,100))
    b=255-r
    
    rgb = np.array([r,g,b]).T
    color_tuple = rgb.transpose((1,0,2)).reshape((rgb.shape[0]*rgb.shape[1],rgb.shape[2]))/255.0
    
    proj = ccrs.LambertConformal(central_longitude=4.9, central_latitude=51.967)

    pl.figure()
    ax = pl.subplot(111, projection=proj)
    ax.set_extent(bbox, ccrs.PlateCarree())

    m = pl.pcolormesh(lon, lat, r, color=color_tuple, linewidth=0, transform=ccrs.PlateCarree())
    m.set_array(None)

#### Traceback


    In [13]: run pcolor_cartopy.py
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    File ~/tmp/pcolor_cartopy.py:38
         35 ax.set_extent(bbox, ccrs.PlateCarree())
         37 m = pl.pcolormesh(lon, lat, r, color=color_tuple, linewidth=0, transform=ccrs.PlateCarree())
    ---> 38 m.set_array(None)
    
    File ~/.local/lib/python3.8/site-packages/cartopy/mpl/geocollection.py:29, in GeoQuadMesh.set_array(self, A)
         27 def set_array(self, A):
         28     # raise right away if A is 2-dimensional.
    ---> 29     if A.ndim > 1:
         30         raise ValueError('Collections can only map rank 1 arrays. '
         31                          'You likely want to call with a flattened array '
         32                          'using collection.set_array(A.ravel()) instead.')
         34     # Only use the mask attribute if it is there.
    
    AttributeError: 'NoneType' object has no attribute 'ndim'

<details>
 <summary>Full environment definition</summary>

<!-- fill in the following information as appropriate -->

### Operating system

Ubuntu 20.04

### Cartopy version

0.21.1

### pip list

```
bart@eddy:~/tmp$ pip list
Package                 Version
----------------------- --------------
affine                  2.4.0
apturl                  0.5.2
asttokens               2.2.1
attrs                   22.2.0
backcall                0.2.0
bcrypt                  3.1.7
blinker                 1.4
Brlapi                  0.7.0
Brotli                  1.0.7
Cartopy                 0.21.1
certifi                 2019.11.28
cftime                  1.6.2
chardet                 3.0.4
chrome-gnome-shell      0.0.0
Click                   7.0
click-plugins           1.1.1
cligj                   0.7.2
cloudpickle             2.2.1
colorama                0.4.3
command-not-found       0.3
contourpy               1.0.7
cryptography            2.8
cupshelpers             1.0
cycler                  0.11.0
dask                    2023.3.0
dbus-python             1.2.16
decorator               5.1.1
defer                   1.0.6
distro                  1.4.0
distro-info             0.23ubuntu1
dnspython               1.16.0
entrypoints             0.3
executing               1.2.0
fonttools               4.38.0
fsspec                  2023.3.0
GDAL                    3.0.4
gpg                     1.13.1-unknown
greenlet                0.4.15
gssapi                  1.6.1
httplib2                0.14.0
idna                    2.8
ifaddr                  0.1.6
importlib-metadata      6.0.0
importlib-resources     5.12.0
ipython                 8.10.0
jedi                    0.18.2
keyring                 18.0.1
kiwisolver              1.4.4
language-selector       0.1
launchpadlib            1.10.13
lazr.restfulclient      0.14.2
lazr.uri                1.0.3
llvmlite                0.39.1
locket                  1.0.0
louis                   3.12.0
lz4                     3.0.2+dfsg
macaroonbakery          1.3.1
Markdown                3.1.1
matplotlib              3.7.0
matplotlib-inline       0.1.6
meld                    3.20.2
msgpack                 0.6.2
netCDF4                 1.6.2
netifaces               0.10.4
nose                    1.3.7
numba                   0.56.4
numpy                   1.23.5
oauthlib                3.1.0
olefile                 0.46
packaging               23.0
pandas                  1.5.3
paramiko                2.6.0
parso                   0.8.3
partd                   1.3.0
pexpect                 4.6.0
pickleshare             0.7.5
Pillow                  7.0.0
pip                     23.0.1
progress                1.6
prompt-toolkit          3.0.37
protobuf                3.6.1
pure-eval               0.2.2
py-cpuinfo              5.0.0
py3dns                  3.2.1
pycairo                 1.16.2
pycrypto                2.6.1
pycups                  1.9.73
Pygments                2.14.0
PyGObject               3.36.0
PyJWT                   1.7.1
pykerberos              1.1.14
pymacaroons             0.13.0
PyNaCl                  1.3.0
pynvim                  0.4.1
PyOpenGL                3.1.0
pyparsing               3.0.9
pyproj                  3.4.1
PyQt5                   5.15.9
PyQt5-Qt5               5.15.2
PyQt5-sip               12.11.1
PyQt6                   6.4.2
PyQt6-Qt6               6.4.2
PyQt6-sip               13.4.1
pyRFC3339               1.1
pyshp                   2.3.1
python-apt              2.0.1
python-dateutil         2.8.2
python-debian           0.1.36ubuntu1
python-lzo              1.12
pytz                    2022.7.1
pyxdg                   0.26
PyYAML                  5.3.1
rasterio                1.3.6
rencode                 1.0.6
reportlab               3.5.34
requests                2.22.0
requests-unixsocket     0.2.0
rioxarray               0.13.4
scipy                   1.10.1
screen-resolution-extra 0.0.0
SecretStorage           2.3.1
setproctitle            1.1.10
setuptools              45.2.0
shapely                 2.0.1
simplejson              3.16.0
six                     1.16.0
snuggs                  1.4.7
ssh-import-id           5.10
stack-data              0.6.2
systemd-python          234
toolz                   0.12.0
traitlets               5.9.0
ubuntu-advantage-tools  8001
ubuntu-drivers-common   0.0.0
ufw                     0.36
unattended-upgrades     0.1
uritools                3.0.0
urllib3                 1.25.8
wadllib                 1.3.3
wcwidth                 0.2.6
wheel                   0.34.2
xarray                  2023.1.0
xkit                    0.0.0
xpra                    3.0.6
zeroconf                0.24.4
zipp                    3.15.0

```

</details>

Problem when using pcolormesh with matplotlib 3.8
### Description
<!-- Please provide a general introduction to the issue/proposal. -->


<!--
If you are reporting a bug, attach the *entire* traceback from Python.

If you are proposing an enhancement/new feature, provide links to related articles, reference examples, etc.

If you are asking a question, please ask on StackOverflow and use the cartopy tag. All cartopy
questions on StackOverflow can be found at https://stackoverflow.com/questions/tagged/cartopy
-->

Problem with colorbar when using pcolormesh with matplotlib 3.8 everything work with 3.7.2 something to do with masked data 

(Try to replace pcolormesh by pcolor but another problem ('Colorbar' object has no attribute '_boundaries')

Don't know if it's a Cartopy or Matplotlib problem...

#### Traceback
File ~/Documents/***/.env/lib/python3.11/site-packages/matplotlib/pyplot.py:2230, in colorbar(mappable, cax, ax, **kwargs)
   2225     if mappable is None:
   2226         raise RuntimeError('No mappable was found to use for colorbar '
   2227                            'creation. First define a mappable such as '
   2228                            'an image (with imshow) or a contour set ('
   2229                            'with contourf).')
-> 2230 ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kwargs)
   2231 return ret

File ~/Documents/***/.env/lib/python3.11/site-packages/matplotlib/figure.py:1295, in FigureBase.colorbar(self, mappable, cax, ax, use_gridspec, **kwargs)
   1291     cax.grid(visible=False, which='both', axis='both')
   1293 NON_COLORBAR_KEYS = [  # remove kws that cannot be passed to Colorbar
   1294     'fraction', 'pad', 'shrink', 'aspect', 'anchor', 'panchor']
-> 1295 cb = cbar.Colorbar(cax, mappable, **{
   1296     k: v for k, v in kwargs.items() if k not in NON_COLORBAR_KEYS})
   1297 cax.figure.stale = True
   1298 return cb

File ~/Documents/***/.env/lib/python3.11/site-packages/matplotlib/colorbar.py:395, in Colorbar.__init__(self, ax, mappable, cmap, norm, alpha, values, boundaries, orientation, ticklocation, extend, spacing, ticks, format, drawedges, extendfrac, extendrect, label, location)
    392 self.ticklocation = ticklocation
    394 self.set_label(label)
--> 395 self._reset_locator_formatter_scale()
    397 if np.iterable(ticks):
    398     self._locator = ticker.FixedLocator(ticks, nbins=len(ticks))

File ~/Documents/***/.env/lib/python3.11/site-packages/matplotlib/colorbar.py:1159, in Colorbar._reset_locator_formatter_scale(self)
   1153 def _reset_locator_formatter_scale(self):
   1154     """
   1155     Reset the locator et al to defaults.  Any user-hardcoded changes
   1156     need to be re-entered if this gets called (either at init, or when
   1157     the mappable normal gets changed: Colorbar.update_normal)
   1158     """
-> 1159     self._process_values()
   1160     self._locator = None
   1161     self._minorlocator = None

File ~/Documents/***/.env/lib/python3.11/site-packages/matplotlib/colorbar.py:1087, in Colorbar._process_values(self)
   1084     b = np.hstack((b, b[-1] + 1))
   1086 # transform from 0-1 to vmin-vmax:
-> 1087 if self.mappable.get_array() is not None:
   1088     self.mappable.autoscale_None()
   1089 if not self.norm.scaled():
   1090     # If we still aren't scaled after autoscaling, use 0, 1 as default

File ~/Documents/***/.env/lib/python3.11/site-packages/cartopy/mpl/geocollection.py:24, in GeoQuadMesh.get_array(self)
     22 # If the input array has a mask, retrieve the associated data
     23 if hasattr(self, '_wrapped_mask'):
---> 24     A[self._wrapped_mask] = self._wrapped_collection_fix.get_array()
     25 return A

File /usr/lib/python3.11/contextlib.py:81, in ContextDecorator.__call__.<locals>.inner(*args, **kwds)
     78 @wraps(func)
     79 def inner(*args, **kwds):
     80     with self._recreate_cm():
---> 81         return func(*args, **kwds)

File ~/Documents/***/.env/lib/python3.11/site-packages/numpy/ma/core.py:3385, in MaskedArray.__setitem__(self, indx, value)
   3383         _data[indx.data] = dval
   3384     else:
-> 3385         _data[indx] = dval
   3386         _mask[indx] = mval
   3387 elif hasattr(indx, 'dtype') and (indx.dtype == MaskType):

<details>
 <summary>Full environment definition</summary>

<!-- fill in the following information as appropriate -->

### Operating system
Ubuntu 23.04

### Cartopy version
0.21.1

### Matplotlib version
3.8.0.dev1496+g2c45571872

</details>



Discussion:

Resolving patch:
diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py
--- a/lib/cartopy/mpl/geoaxes.py
+++ b/lib/cartopy/mpl/geoaxes.py
@@ -45,7 +45,8 @@
 from cartopy.mpl.slippy_image_artist import SlippyImageArtist
 
 
-assert packaging.version.parse(mpl.__version__).release[:2] >= (3, 4), \
+_MPL_VERSION = packaging.version.parse(mpl.__version__)
+assert _MPL_VERSION.release >= (3, 4), \
     'Cartopy is only supported with Matplotlib 3.4 or greater.'
 
 # A nested mapping from path, source CRS, and target projection to the
@@ -1796,7 +1797,7 @@ def _wrap_args(self, *args, **kwargs):
         kwargs['shading'] = 'flat'
         X = np.asanyarray(args[0])
         Y = np.asanyarray(args[1])
-        nrows, ncols = np.asanyarray(args[2]).shape
+        nrows, ncols = np.asanyarray(args[2]).shape[:2]
         Nx = X.shape[-1]
         Ny = Y.shape[0]
         if X.ndim != 2 or X.shape[0] == 1:
@@ -1843,12 +1844,13 @@ def _wrap_quadmesh(self, collection, **kwargs):
         Ny, Nx, _ = coords.shape
         if kwargs.get('shading') == 'gouraud':
             # Gouraud shading has the same shape for coords and data
-            data_shape = Ny, Nx
+            data_shape = Ny, Nx, -1
         else:
-            data_shape = Ny - 1, Nx - 1
+            data_shape = Ny - 1, Nx - 1, -1
         # data array
         C = collection.get_array().reshape(data_shape)
-
+        if C.shape[-1] == 1:
+            C = C.squeeze(axis=-1)
         transformed_pts = self.projection.transform_points(
             t, coords[..., 0], coords[..., 1])
 
@@ -1921,13 +1923,12 @@ def _wrap_quadmesh(self, collection, **kwargs):
                           "map it must be fully transparent.",
                           stacklevel=3)
 
-        # The original data mask (regardless of wrapped cells)
-        C_mask = getattr(C, 'mask', None)
+        # Get hold of masked versions of the array to be passed to set_array
+        # methods of QuadMesh and PolyQuadMesh
+        pcolormesh_data, pcolor_data, pcolor_mask = \
+            cartopy.mpl.geocollection._split_wrapped_mesh_data(C, mask)
 
-        # create the masked array to be used with this pcolormesh
-        full_mask = mask if C_mask is None else mask | C_mask
-        pcolormesh_data = np.ma.array(C, mask=full_mask)
-        collection.set_array(pcolormesh_data.ravel())
+        collection.set_array(pcolormesh_data)
 
         # plot with slightly lower zorder to avoid odd issue
         # where the main plot is obscured
@@ -1943,25 +1944,32 @@ def _wrap_quadmesh(self, collection, **kwargs):
         # `pcolor` only draws polygons where the data is not
         # masked, so this will only draw a limited subset of
         # polygons that were actually wrapped.
-        # We will add the original data mask in later to
-        # make sure that set_array can work in future
-        # calls on the proper sized array inputs.
-        # NOTE: we don't use C.data here because C.data could
-        #       contain nan's which would be masked in the
-        #       pcolor routines, which we don't want. We will
-        #       fill in the proper data later with set_array()
-        #       calls.
-        pcolor_data = np.ma.array(np.zeros(C.shape),
-                                  mask=~mask)
-        pcolor_col = self.pcolor(coords[..., 0], coords[..., 1],
-                                 pcolor_data, zorder=zorder,
-                                 **kwargs)
-        # Now add back in the masked data if there was any
-        full_mask = ~mask if C_mask is None else ~mask | C_mask
-        pcolor_data = np.ma.array(C, mask=full_mask)
-        # The pcolor_col is now possibly shorter than the
-        # actual collection, so grab the masked cells
-        pcolor_col.set_array(pcolor_data[mask].ravel())
+
+        if _MPL_VERSION.release[:2] < (3, 8):
+            # We will add the original data mask in later to
+            # make sure that set_array can work in future
+            # calls on the proper sized array inputs.
+            # NOTE: we don't use C.data here because C.data could
+            #       contain nan's which would be masked in the
+            #       pcolor routines, which we don't want. We will
+            #       fill in the proper data later with set_array()
+            #       calls.
+            pcolor_zeros = np.ma.array(np.zeros(C.shape), mask=pcolor_mask)
+            pcolor_col = self.pcolor(coords[..., 0], coords[..., 1],
+                                     pcolor_zeros, zorder=zorder,
+                                     **kwargs)
+
+            # The pcolor_col is now possibly shorter than the
+            # actual collection, so grab the masked cells
+            pcolor_col.set_array(pcolor_data[mask].ravel())
+        else:
+            pcolor_col = self.pcolor(coords[..., 0], coords[..., 1],
+                                     pcolor_data, zorder=zorder,
+                                     **kwargs)
+            # Currently pcolor_col.get_array() will return a compressed array
+            # and warn unless we explicitly set the 2D array.  This should be
+            # unnecessary with future matplotlib versions.
+            pcolor_col.set_array(pcolor_data)
 
         pcolor_col.set_cmap(cmap)
         pcolor_col.set_norm(norm)
@@ -1972,7 +1980,7 @@ def _wrap_quadmesh(self, collection, **kwargs):
         # put the pcolor_col and mask on the pcolormesh
         # collection so that users can do things post
         # this method
-        collection._wrapped_mask = mask.ravel()
+        collection._wrapped_mask = mask
         collection._wrapped_collection_fix = pcolor_col
 
         return collection
diff --git a/lib/cartopy/mpl/geocollection.py b/lib/cartopy/mpl/geocollection.py
--- a/lib/cartopy/mpl/geocollection.py
+++ b/lib/cartopy/mpl/geocollection.py
@@ -3,8 +3,43 @@
 # This file is part of Cartopy and is released under the LGPL license.
 # See COPYING and COPYING.LESSER in the root of the repository for full
 # licensing details.
+import matplotlib as mpl
 from matplotlib.collections import QuadMesh
 import numpy as np
+import numpy.ma as ma
+import packaging
+
+
+_MPL_VERSION = packaging.version.parse(mpl.__version__)
+
+
+def _split_wrapped_mesh_data(C, mask):
+    """
+    Helper function for splitting GeoQuadMesh array values between the
+    pcolormesh and pcolor objects when wrapping.  Apply a mask to the grid
+    cells that should not be plotted with each method.
+
+    """
+    # The original data mask (regardless of wrapped cells)
+    C_mask = getattr(C, 'mask', None)
+    if C.ndim == 3:
+        # RGB(A) array.
+        if _MPL_VERSION.release < (3, 8):
+            raise ValueError("GeoQuadMesh wrapping for RGB(A) requires "
+                             "Matplotlib v3.8 or later")
+
+        # mask will need an extra trailing dimension
+        mask = np.broadcast_to(mask[..., np.newaxis], C.shape)
+
+    # create the masked array to be used with pcolormesh
+    full_mask = mask if C_mask is None else mask | C_mask
+    pcolormesh_data = ma.array(C, mask=full_mask)
+
+    # create the masked array to be used with pcolor
+    full_mask = ~mask if C_mask is None else ~mask | C_mask
+    pcolor_data = ma.array(C, mask=full_mask)
+
+    return pcolormesh_data, pcolor_data, ~mask
 
 
 class GeoQuadMesh(QuadMesh):
@@ -21,25 +56,57 @@ def get_array(self):
         A = super().get_array().copy()
         # If the input array has a mask, retrieve the associated data
         if hasattr(self, '_wrapped_mask'):
-            A[self._wrapped_mask] = self._wrapped_collection_fix.get_array()
+            pcolor_data = self._wrapped_collection_fix.get_array()
+            mask = self._wrapped_mask
+            if _MPL_VERSION.release[:2] < (3, 8):
+                A[mask] = pcolor_data
+            else:
+                if A.ndim == 3:  # RGB(A) data.  Need to broadcast mask.
+                    mask = mask[:, :, np.newaxis]
+                # np.copyto is not implemented for masked arrays so handle the
+                # mask explicitly
+                np.copyto(A.mask, pcolor_data.mask, where=mask)
+                np.copyto(A, pcolor_data, where=mask)
+
         return A
 
     def set_array(self, A):
-        # raise right away if A is 2-dimensional.
-        if A.ndim > 1:
-            raise ValueError('Collections can only map rank 1 arrays. '
-                             'You likely want to call with a flattened array '
-                             'using collection.set_array(A.ravel()) instead.')
+        # Check the shape is appropriate up front.
+        if _MPL_VERSION.release[:2] < (3, 8):
+            # Need to figure out existing shape from the coordinates.
+            height, width = self._coordinates.shape[0:-1]
+            if self._shading == 'flat':
+                h, w = height - 1, width - 1
+            else:
+                h, w = height, width
+        else:
+            h, w = super().get_array().shape[:2]
+
+        ok_shapes = [(h, w, 3), (h, w, 4), (h, w), (h * w,)]
+        if A.shape not in ok_shapes:
+            ok_shape_str = ' or '.join(map(str, ok_shapes))
+            raise ValueError(
+                f"A should have shape {ok_shape_str}, not {A.shape}")
+
+        if A.ndim == 1:
+            # Always use array with at least two dimensions.  This is
+            # inconsistent with QuadMesh which stores whatever you give it, but
+            # for the wrapped case we need to match the 2D mask.  Storing the
+            # 2D array also allows us to calculate ok_shapes on subsequent
+            # calls without using the private QuadMesh._shading attribute.
+            A = A.reshape((h, w))
 
         # Only use the mask attribute if it is there.
         if hasattr(self, '_wrapped_mask'):
+
             # Update the pcolor data with the wrapped masked data
-            self._wrapped_collection_fix.set_array(A[self._wrapped_mask])
-            # If the input array was a masked array, keep that data masked
-            if hasattr(A, 'mask'):
-                A = np.ma.array(A, mask=self._wrapped_mask | A.mask)
+            A, pcolor_data, _ = _split_wrapped_mesh_data(A, self._wrapped_mask)
+
+            if _MPL_VERSION.release[:2] < (3, 8):
+                self._wrapped_collection_fix.set_array(
+                    pcolor_data[self._wrapped_mask].ravel())
             else:
-                A = np.ma.array(A, mask=self._wrapped_mask)
+                self._wrapped_collection_fix.set_array(pcolor_data)
 
         # Now that we have prepared the collection data, call on
         # through to the underlying implementation.


Test patch:
diff --git a/lib/cartopy/tests/mpl/test_mpl_integration.py b/lib/cartopy/tests/mpl/test_mpl_integration.py
--- a/lib/cartopy/tests/mpl/test_mpl_integration.py
+++ b/lib/cartopy/tests/mpl/test_mpl_integration.py
@@ -6,6 +6,7 @@
 
 import re
 
+import matplotlib.colors as mcolors
 import matplotlib.pyplot as plt
 import numpy as np
 import pytest
@@ -240,10 +241,46 @@ def test_cursor_values():
                      r.encode('ascii', 'ignore'))
 
 
+SKIP_PRE_MPL38 = pytest.mark.skipif(
+    MPL_VERSION.release[:2] < (3, 8), reason='mpl < 3.8')
+PARAMETRIZE_PCOLORMESH_WRAP = pytest.mark.parametrize(
+    'mesh_data_kind',
+    [
+        'standard',
+        pytest.param('rgb', marks=SKIP_PRE_MPL38),
+        pytest.param('rgba', marks=SKIP_PRE_MPL38),
+    ],
+    ids=['standard', 'rgb', 'rgba'],
+)
+
+
+def _to_rgb(data, mesh_data_kind):
+    """
+    Helper function to convert array to RGB(A) where required
+    """
+    if mesh_data_kind in ('rgb', 'rgba'):
+        cmap = plt.get_cmap()
+        norm = mcolors.Normalize()
+        new_data = cmap(norm(data))
+        if mesh_data_kind == 'rgb':
+            new_data = new_data[..., 0:3]
+            if np.ma.is_masked(data):
+                # Use data's mask as an alpha channel
+                mask = np.ma.getmaskarray(data)
+                mask = np.broadcast_to(
+                    mask[..., np.newaxis], new_data.shape).copy()
+                new_data = np.ma.array(new_data, mask=mask)
+
+        return new_data
+
+    return data
+
+
+@PARAMETRIZE_PCOLORMESH_WRAP
 @pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='pcolormesh_global_wrap1.png',
                                tolerance=1.27)
-def test_pcolormesh_global_with_wrap1():
+def test_pcolormesh_global_with_wrap1(mesh_data_kind):
     # make up some realistic data with bounds (such as data from the UM)
     nx, ny = 36, 18
     xbnds = np.linspace(0, 360, nx, endpoint=True)
@@ -254,6 +291,8 @@ def test_pcolormesh_global_with_wrap1():
     data = data[:-1, :-1]
     fig = plt.figure()
 
+    data = _to_rgb(data, mesh_data_kind)
+
     ax = fig.add_subplot(2, 1, 1, projection=ccrs.PlateCarree())
     ax.pcolormesh(xbnds, ybnds, data, transform=ccrs.PlateCarree(), snap=False)
     ax.coastlines()
@@ -267,7 +306,8 @@ def test_pcolormesh_global_with_wrap1():
     return fig
 
 
-def test_pcolormesh_get_array_with_mask():
+@PARAMETRIZE_PCOLORMESH_WRAP
+def test_pcolormesh_get_array_with_mask(mesh_data_kind):
     # make up some realistic data with bounds (such as data from the UM)
     nx, ny = 36, 18
     xbnds = np.linspace(0, 360, nx, endpoint=True)
@@ -275,7 +315,10 @@ def test_pcolormesh_get_array_with_mask():
 
     x, y = np.meshgrid(xbnds, ybnds)
     data = np.exp(np.sin(np.deg2rad(x)) + np.cos(np.deg2rad(y)))
+    data[5, :] = np.nan  # Check that missing data is handled - GH#2208
     data = data[:-1, :-1]
+    data = _to_rgb(data, mesh_data_kind)
+
     fig = plt.figure()
 
     ax = fig.add_subplot(2, 1, 1, projection=ccrs.PlateCarree())
@@ -284,9 +327,10 @@ def test_pcolormesh_get_array_with_mask():
         'No pcolormesh wrapping was done when it should have been.'
 
     result = c.get_array()
-    assert not np.ma.is_masked(result)
-    assert np.array_equal(data.ravel(), result), \
-        'Data supplied does not match data retrieved in wrapped case'
+    np.testing.assert_array_equal(np.ma.getmask(result), np.isnan(data))
+    np.testing.assert_array_equal(
+        data, result,
+        err_msg='Data supplied does not match data retrieved in wrapped case')
 
     ax.coastlines()
     ax.set_global()  # make sure everything is visible
@@ -298,7 +342,9 @@ def test_pcolormesh_get_array_with_mask():
 
     x, y = np.meshgrid(xbnds, ybnds)
     data = np.exp(np.sin(np.deg2rad(x)) + np.cos(np.deg2rad(y)))
+    data[5, :] = np.nan
     data2 = data[:-1, :-1]
+    data2 = _to_rgb(data2, mesh_data_kind)
 
     ax = fig.add_subplot(2, 1, 2, projection=ccrs.PlateCarree())
     c = ax.pcolormesh(xbnds, ybnds, data2, transform=ccrs.PlateCarree())
@@ -309,15 +355,22 @@ def test_pcolormesh_get_array_with_mask():
         'pcolormesh wrapping was done when it should not have been.'
 
     result = c.get_array()
-    assert not np.ma.is_masked(result)
-    assert np.array_equal(data2.ravel(), result), \
-        'Data supplied does not match data retrieved in unwrapped case'
+
+    expected = data2
+    if MPL_VERSION.release[:2] < (3, 8):
+        expected = expected.ravel()
+
+    np.testing.assert_array_equal(np.ma.getmask(result), np.isnan(expected))
+    np.testing.assert_array_equal(
+        expected, result,
+        'Data supplied does not match data retrieved in unwrapped case')
 
 
+@PARAMETRIZE_PCOLORMESH_WRAP
 @pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='pcolormesh_global_wrap2.png',
                                tolerance=1.87)
-def test_pcolormesh_global_with_wrap2():
+def test_pcolormesh_global_with_wrap2(mesh_data_kind):
     # make up some realistic data with bounds (such as data from the UM)
     nx, ny = 36, 18
     xbnds, xstep = np.linspace(0, 360, nx - 1, retstep=True, endpoint=True)
@@ -332,6 +385,8 @@ def test_pcolormesh_global_with_wrap2():
     data = data[:-1, :-1]
     fig = plt.figure()
 
+    data = _to_rgb(data, mesh_data_kind)
+
     ax = fig.add_subplot(2, 1, 1, projection=ccrs.PlateCarree())
     ax.pcolormesh(xbnds, ybnds, data, transform=ccrs.PlateCarree(), snap=False)
     ax.coastlines()
@@ -345,10 +400,11 @@ def test_pcolormesh_global_with_wrap2():
     return fig
 
 
+@PARAMETRIZE_PCOLORMESH_WRAP
 @pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='pcolormesh_global_wrap3.png',
                                tolerance=1.42)
-def test_pcolormesh_global_with_wrap3():
+def test_pcolormesh_global_with_wrap3(mesh_data_kind):
     nx, ny = 33, 17
     xbnds = np.linspace(-1.875, 358.125, nx, endpoint=True)
     ybnds = np.linspace(91.25, -91.25, ny, endpoint=True)
@@ -366,6 +422,8 @@ def test_pcolormesh_global_with_wrap3():
     data = np.ma.masked_greater(data, 2.6)
     fig = plt.figure()
 
+    data = _to_rgb(data, mesh_data_kind)
+
     ax = fig.add_subplot(3, 1, 1, projection=ccrs.PlateCarree(-45))
     c = ax.pcolormesh(xbnds, ybnds, data, transform=ccrs.PlateCarree(),
                       snap=False)
@@ -388,10 +446,11 @@ def test_pcolormesh_global_with_wrap3():
     return fig
 
 
+@PARAMETRIZE_PCOLORMESH_WRAP
 @pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='pcolormesh_global_wrap3.png',
                                tolerance=1.42)
-def test_pcolormesh_set_array_with_mask():
+def test_pcolormesh_set_array_with_mask(mesh_data_kind):
     """Testing that set_array works with masked arrays properly."""
     nx, ny = 33, 17
     xbnds = np.linspace(-1.875, 358.125, nx, endpoint=True)
@@ -414,10 +473,15 @@ def test_pcolormesh_set_array_with_mask():
     bad_data_mask = np.ma.array(bad_data, mask=~data.mask)
     fig = plt.figure()
 
+    data = _to_rgb(data, mesh_data_kind)
+    bad_data = _to_rgb(bad_data, mesh_data_kind)
+    bad_data_mask = _to_rgb(bad_data_mask, mesh_data_kind)
+
     ax = fig.add_subplot(3, 1, 1, projection=ccrs.PlateCarree(-45))
     c = ax.pcolormesh(xbnds, ybnds, bad_data,
                       norm=norm, transform=ccrs.PlateCarree(), snap=False)
-    c.set_array(data.ravel())
+
+    c.set_array(data)
     assert c._wrapped_collection_fix is not None, \
         'No pcolormesh wrapping was done when it should have been.'
 
@@ -427,7 +491,10 @@ def test_pcolormesh_set_array_with_mask():
     ax = fig.add_subplot(3, 1, 2, projection=ccrs.PlateCarree(-1.87499952))
     c2 = ax.pcolormesh(xbnds, ybnds, bad_data_mask,
                        norm=norm, transform=ccrs.PlateCarree(), snap=False)
-    c2.set_array(data.ravel())
+    if mesh_data_kind == 'standard':
+        c2.set_array(data.ravel())
+    else:
+        c2.set_array(data)
     ax.coastlines()
     ax.set_global()  # make sure everything is visible
 
@@ -439,6 +506,37 @@ def test_pcolormesh_set_array_with_mask():
     return fig
 
 
+def test_pcolormesh_set_array_nowrap():
+    # Roundtrip check that set_array works with the correct shaped arrays
+    nx, ny = 36, 18
+    xbnds = np.linspace(-60, 60, nx, endpoint=True)
+    ybnds = np.linspace(-80, 80, ny, endpoint=True)
+    xbnds, ybnds = np.meshgrid(xbnds, ybnds)
+
+    rng = np.random.default_rng()
+    data = rng.random((ny - 1, nx - 1))
+
+    ax = plt.figure().add_subplot(projection=ccrs.PlateCarree())
+    mesh = ax.pcolormesh(xbnds, ybnds, data)
+    assert not hasattr(mesh, '_wrapped_collection_fix')
+
+    expected = data
+    if MPL_VERSION.release[:2] < (3, 8):
+        expected = expected.ravel()
+    np.testing.assert_array_equal(mesh.get_array(), expected)
+
+    # For backwards compatibility, check we can set a 1D array
+    data = rng.random((nx - 1) * (ny - 1))
+    mesh.set_array(data)
+    np.testing.assert_array_equal(
+        mesh.get_array(), data.reshape(ny - 1, nx - 1))
+
+    # Check that we can set a 2D array even if previous was flat
+    data = rng.random((ny - 1, nx - 1))
+    mesh.set_array(data)
+    np.testing.assert_array_equal(mesh.get_array(), data)
+
+
 @pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='pcolormesh_global_wrap3.png',
                                tolerance=1.42)
@@ -583,6 +681,13 @@ def test_pcolormesh_nan_wrap():
     ax = plt.axes(projection=ccrs.PlateCarree())
     mesh = ax.pcolormesh(xs, ys, data)
     pcolor = getattr(mesh, "_wrapped_collection_fix")
+    if MPL_VERSION.release[:2] < (3, 8):
+        assert len(pcolor.get_paths()) == 2
+    else:
+        assert not pcolor.get_paths()
+
+    # Check that we can populate the pcolor with some data.
+    mesh.set_array(np.ones((2, 2)))
     assert len(pcolor.get_paths()) == 2
 
 
@@ -617,14 +722,18 @@ def test_pcolormesh_mercator_wrap():
     return ax.figure
 
 
+@PARAMETRIZE_PCOLORMESH_WRAP
 @pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='pcolormesh_mercator_wrap.png')
-def test_pcolormesh_wrap_set_array():
+def test_pcolormesh_wrap_set_array(mesh_data_kind):
     x = np.linspace(0, 360, 73)
     y = np.linspace(-87.5, 87.5, 36)
     X, Y = np.meshgrid(*[np.deg2rad(c) for c in (x, y)])
     Z = np.cos(Y) + 0.375 * np.sin(2. * X)
     Z = Z[:-1, :-1]
+
+    Z = _to_rgb(Z, mesh_data_kind)
+
     ax = plt.axes(projection=ccrs.Mercator())
     norm = plt.Normalize(np.min(Z), np.max(Z))
     ax.coastlines()
@@ -632,7 +741,7 @@ def test_pcolormesh_wrap_set_array():
     coll = ax.pcolormesh(x, y, np.ones(Z.shape), norm=norm,
                          transform=ccrs.PlateCarree(), snap=False)
     # Now update the plot with the set_array method
-    coll.set_array(Z.ravel())
+    coll.set_array(Z)
     return ax.figure