Repository: nipy/nipype

Issue:
matplotlib "normed" argument deprecated
### Summary
When trying to use the nipype.algorithms.metrics.Distance with method='eucl_mean', get the following error
`AttributeError: 'Rectangle' object has no property 'normed'`

My two input volumes are z-stat map outputs from fitlins of the same individual (both are in same shape/dimensions).

It seems like the normed argument is deprecated in matplotlib.

### Actual behavior
The following error
```
~/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/nipype/interfaces/base/core.py in run(self, cwd, ignore_exception, **inputs)
    426         try:
    427             runtime = self._pre_run_hook(runtime)
--> 428             runtime = self._run_interface(runtime)
    429             runtime = self._post_run_hook(runtime)
    430             outputs = self.aggregate_outputs(runtime)

~/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/nipype/algorithms/metrics.py in _run_interface(self, runtime)
    200 
    201         elif self.inputs.method == "eucl_mean":
--> 202             self._distance = self._eucl_mean(nii1, nii2)
    203 
    204         elif self.inputs.method == "eucl_wmean":

~/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/nipype/algorithms/metrics.py in _eucl_mean(self, nii1, nii2, weighted)
    151 
    152         plt.figure()
--> 153         plt.hist(min_dist_matrix, 50, normed=1, facecolor="green")
    154         plt.savefig(self._hist_filename)
    155         plt.clf()

~/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/matplotlib/pyplot.py in hist(x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, data, **kwargs)
   2683         orientation='vertical', rwidth=None, log=False, color=None,
   2684         label=None, stacked=False, *, data=None, **kwargs):
-> 2685     return gca().hist(
   2686         x, bins=bins, range=range, density=density, weights=weights,
   2687         cumulative=cumulative, bottom=bottom, histtype=histtype,

~/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1445     def inner(ax, *args, data=None, **kwargs):
   1446         if data is None:
-> 1447             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1448 
   1449         bound = new_sig.bind(ax, *args, **kwargs)

~/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/matplotlib/axes/_axes.py in hist(self, x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
   6813             if patch:
   6814                 p = patch[0]
-> 6815                 p.update(kwargs)
   6816                 if lbl is not None:
   6817                     p.set_label(lbl)

~/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/matplotlib/artist.py in update(self, props)
    994                     func = getattr(self, f"set_{k}", None)
    995                     if not callable(func):
--> 996                         raise AttributeError(f"{type(self).__name__!r} object "
    997                                              f"has no property {k!r}")
    998                     ret.append(func(v))

AttributeError: 'Rectangle' object has no property 'normed'
```

### Expected behavior
Histogram output

### Platform details:

<!-- Please run the following code from your shell and place the output between the triple ticks, below.
python -c "import nipype; from pprint import pprint; pprint(nipype.get_info())"
-->

```
{'commit_hash': '0289137',
 'commit_source': 'installation',
 'networkx_version': '2.5.1',
 'nibabel_version': '2.5.1',
 'nipype_version': '1.6.1',
 'numpy_version': '1.20.3',
 'pkg_path': '/home/users/sjshim/miniconda3/envs/fmri_analysis/lib/python3.9/site-packages/nipype',
 'scipy_version': '1.5.3',
 'sys_executable': '/home/users/sjshim/miniconda3/envs/fmri_analysis/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.9.7 (default, Sep 16 2021, 13:09:58) \n[GCC 7.5.0]',
 'traits_version': '6.2.0'}
```



Discussion:
Hi @sjshim. Could you try to find what version of matplotlib dropped it, and if it's either become the default behavior or needs to be specified elsewhere? (If you're unclear how to go about that, I'm happy to help...)
I'm not sure what version of matplotlib dropped it. I tried installing older versions of matplotlib in the conda environment used to run the above script to something like ver 1.2.1 but still saw the error, although it might have been other requirements clashing with the version.

I did find the following documentation which suggests to use 'density' instead of 'normed':
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.hist.html
Great, thanks for digging! Would you mind making a PR switching the normed keyword for density? I can see if I can find what minimum version that puts us at.
Looks like there's a minimum `matplotlib` of 2.1 for this (added in https://github.com/matplotlib/matplotlib/pull/8993). But it also looks like we don't explicitly require matplotlib, so there's no minimum version to update.

Resolving patch:
diff --git a/nipype/algorithms/metrics.py b/nipype/algorithms/metrics.py
--- a/nipype/algorithms/metrics.py
+++ b/nipype/algorithms/metrics.py
@@ -150,7 +150,7 @@ def _eucl_mean(self, nii1, nii2, weighted=False):
         import matplotlib.pyplot as plt
 
         plt.figure()
-        plt.hist(min_dist_matrix, 50, normed=1, facecolor="green")
+        plt.hist(min_dist_matrix, 50, density=True, facecolor="green")
         plt.savefig(self._hist_filename)
         plt.clf()
         plt.close()


Test patch: