Repository: nilearn/nilearn

Issue:
plot_carpet's cmap option doesn't work
<!--Provide a brief description of the bug.-->

carpet_plot does not respect cmap argument.

<!--Please fill in the following information, to the best of your ability.-->
Nilearn version:

0.9.1dev

### Expected behavior
Passing cmap changes color of plot.

### Actual behavior
Plot is gray regardless of cmap value.

### Steps and code to reproduce bug

```python
from nilearn import datasets, plotting
import tempfile

data_spm = datasets.fetch_spm_auditory(
    data_dir=tempfile.mkdtemp(),
    data_name="spm_auditory",
    subject_id="sub001",
    verbose=1,
)
data = image.load_img(data_spm["func"])
plotting.plot_carpet(data, cmap="viridis")
```



Discussion:
Oops, indeed. PR welcome !
@dangom the `cmap` argument should only have an effect if an atlas is used (i.e., if `mask_img` is an atlas), since it only impacts the colorbar on the left side of the figure:

<img src="https://user-images.githubusercontent.com/8228902/161290743-e29829b8-bf68-46a4-8c13-7edade9c6fcb.png" width="300" />

This may be a documentation issue, rather than a bug. Or perhaps an opportunity for a new parameter, if you want to change the actual heatmap's colormap.

Resolving patch:
diff --git a/examples/01_plotting/plot_carpet.py b/examples/01_plotting/plot_carpet.py
--- a/examples/01_plotting/plot_carpet.py
+++ b/examples/01_plotting/plot_carpet.py
@@ -76,6 +76,7 @@
     t_r=t_r,
     mask_labels=map_labels,
     axes=ax,
+    cmap="gray",
 )
 
 fig.show()
diff --git a/nilearn/plotting/img_plotting.py b/nilearn/plotting/img_plotting.py
--- a/nilearn/plotting/img_plotting.py
+++ b/nilearn/plotting/img_plotting.py
@@ -1308,7 +1308,7 @@ def plot_markers(node_values, node_coords, node_size='auto',
 def plot_carpet(img, mask_img=None, mask_labels=None, t_r=None,
                 detrend=True, output_file=None,
                 figure=None, axes=None, vmin=None, vmax=None, title=None,
-                cmap=plt.cm.gist_ncar):
+                cmap="gray", cmap_labels=plt.cm.gist_ncar):
     """Plot an image representation of voxel intensities across time.
 
     This figure is also known as a "grayplot" or "Power plot".
@@ -1350,8 +1350,12 @@ def plot_carpet(img, mask_img=None, mask_labels=None, t_r=None,
     %(title)s
     %(cmap)s
 
-        .. note::
-            This argument is used only if an atlas is used.
+        Default=`gray`.
+
+    cmap_labels : :class:`matplotlib.colors.Colormap`, or :obj:`str`,
+        optional If ``mask_img`` corresponds to an atlas, then cmap_labels
+        can be used to define the colormap for coloring the labels placed
+        on the side of the carpet plot.
 
         Default=`plt.cm.gist_ncar`.
 
@@ -1462,7 +1466,7 @@ def plot_carpet(img, mask_img=None, mask_labels=None, t_r=None,
             atlas_values[:, np.newaxis],
             interpolation='none',
             aspect='auto',
-            cmap=cmap
+            cmap=cmap_labels
         )
         if mask_labels:
             # Add labels to middle of each associated band
@@ -1484,7 +1488,7 @@ def plot_carpet(img, mask_img=None, mask_labels=None, t_r=None,
             data.T,
             interpolation='nearest',
             aspect='auto',
-            cmap='gray',
+            cmap=cmap,
             vmin=vmin or default_vmin,
             vmax=vmax or default_vmax,
         )
@@ -1494,7 +1498,7 @@ def plot_carpet(img, mask_img=None, mask_labels=None, t_r=None,
             data.T,
             interpolation='nearest',
             aspect='auto',
-            cmap='gray',
+            cmap=cmap,
             vmin=vmin or default_vmin,
             vmax=vmax or default_vmax,
         )


Test patch: