Sc.pl.matrixplot mean_only_expressed broken or just me?

Hi all,

When attempt to run sc.pl.MatrixPlot with the mean_only_expressed=True argument I get an error. The argument does work for sc.pl.dotplot though.

scanpy 1.7.1
matplotlib 3.3.4

Any suggestions?

Traceback
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-60-5352dec1114c> in <module>
----> 1 sc.pl.MatrixPlot(i2, plot_markers, groupby='pheno', mean_only_expressed=True).show()

C:\ProgramData\Anaconda3\lib\site-packages\scanpy\plotting\_baseplot_class.py in show(self, return_axes)
    762         """
    763 
--> 764         self.make_figure()
    765 
    766         if return_axes:

C:\ProgramData\Anaconda3\lib\site-packages\scanpy\plotting\_baseplot_class.py in make_figure(self)
    721 
    722         # plot the mainplot
--> 723         normalize = self._mainplot(main_ax)
    724 
    725         # code from pandas.plot in add_totals adds

C:\ProgramData\Anaconda3\lib\site-packages\scanpy\plotting\_matrixplot.py in _mainplot(self, ax)
    220             norm=normalize,
    221         )
--> 222         __ = ax.pcolor(_color_df, **kwds)
    223 
    224         y_labels = _color_df.index

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, data, *args, **kwargs)
   1429     def inner(ax, *args, data=None, **kwargs):
   1430         if data is None:
-> 1431             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1432 
   1433         bound = new_sig.bind(ax, *args, **kwargs)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in pcolor(self, shading, alpha, norm, cmap, vmin, vmax, *args, **kwargs)
   5850         kwargs.setdefault('snap', False)
   5851 
-> 5852         collection = mcoll.PolyCollection(verts, **kwargs)
   5853 
   5854         collection.set_alpha(alpha)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in __init__(self, verts, sizes, closed, **kwargs)
   1121             Forwarded to `.Collection`.
   1122         """
-> 1123         Collection.__init__(self, **kwargs)
   1124         self.set_sizes(sizes)
   1125         self.set_verts(verts, closed)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
    211 
    212         self._path_effects = None
--> 213         self.update(kwargs)
    214         self._paths = None
    215 

C:\ProgramData\Anaconda3\lib\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: 'PolyCollection' object has no property 'mean_only_expressed'

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-60-5352dec1114c> in <module>
----> 1 sc.pl.MatrixPlot(i2, plot_markers, groupby='pheno', mean_only_expressed=True).show()

C:\ProgramData\Anaconda3\lib\site-packages\scanpy\plotting\_baseplot_class.py in show(self, return_axes)
    762         """
    763 
--> 764         self.make_figure()
    765 
    766         if return_axes:

C:\ProgramData\Anaconda3\lib\site-packages\scanpy\plotting\_baseplot_class.py in make_figure(self)
    721 
    722         # plot the mainplot
--> 723         normalize = self._mainplot(main_ax)
    724 
    725         # code from pandas.plot in add_totals adds

C:\ProgramData\Anaconda3\lib\site-packages\scanpy\plotting\_matrixplot.py in _mainplot(self, ax)
    220             norm=normalize,
    221         )
--> 222         __ = ax.pcolor(_color_df, **kwds)
    223 
    224         y_labels = _color_df.index

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, data, *args, **kwargs)
   1429     def inner(ax, *args, data=None, **kwargs):
   1430         if data is None:
-> 1431             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1432 
   1433         bound = new_sig.bind(ax, *args, **kwargs)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in pcolor(self, shading, alpha, norm, cmap, vmin, vmax, *args, **kwargs)
   5850         kwargs.setdefault('snap', False)
   5851 
-> 5852         collection = mcoll.PolyCollection(verts, **kwargs)
   5853 
   5854         collection.set_alpha(alpha)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in __init__(self, verts, sizes, closed, **kwargs)
   1121             Forwarded to `.Collection`.
   1122         """
-> 1123         Collection.__init__(self, **kwargs)
   1124         self.set_sizes(sizes)
   1125         self.set_verts(verts, closed)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
    211 
    212         self._path_effects = None
--> 213         self.update(kwargs)
    214         self._paths = None
    215 

C:\ProgramData\Anaconda3\lib\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: 'PolyCollection' object has no property 'mean_only_expressed'

Thanks for letting us know! This seems like a bug. Could you please open a bug report on the issue tracker?