rasbt / mlxtend

A library of extension and helper modules for Python's data analysis and machine learning libraries.
https://rasbt.github.io/mlxtend/
Other
4.85k stars 857 forks source link

```matplotlib 3.4.1``` breaks ```plot_decision_regions``` when using ```X_highlight``` #819

Closed khliland closed 3 years ago

khliland commented 3 years ago

Thank you for a very useful package and book (Python Machine Learning)!

Describe the bug

matplotlib 3.4.1 no longer accepts the face color parameter 'c' to be an empty string. In mlxtend the empty string was used to create circles with transparent face color when highlighting samples, e.g. test data, through the parameter X_highlight in plot_decision_regions.

Steps/Code to Reproduce

  1. import matplotlib 3.4.1
  2. Train classifier
  3. Use plot_decision_regions with X_highlight

Suggested fix

Change defaults on line 292 in https://github.com/rasbt/mlxtend/blob/master/mlxtend/plotting/decision_regions.py from:

        scatter_highlight_defaults = {'c': '',
                                      'edgecolor': 'black',
                                      'alpha': 1.0,
                                      'linewidths': 1,
                                      'marker': 'o',
                                      's': 80}

to

        scatter_highlight_defaults = {'c': 'none',
                                      'facecolors': 'none',
                                      'edgecolor': 'black',
                                      'alpha': 1.0,
                                      'linewidths': 1,
                                      'marker': 'o',
                                      's': 80}

Versions

MLxtend 0.18.0 Windows-10-10.0.18362-SP0 Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] Scikit-learn 0.21.3 NumPy 1.17.2 SciPy 1.3.1 matplotlib 3.4.1

rasbt commented 3 years ago

Thanks a lot for the note! Just went ahead and fixed it in #822

heplesser commented 3 years ago

@rasbt Do you expect to provide a new release of mlxtend containing this fix in the near future? It would make teaching (using your book) much easier to have a mlxtend version working out of the box with current matplotlib. Particularly in introductory courses it is an advantage if students can just do a straight conda or pip install of packages instead of having to install from Github.

rasbt commented 3 years ago

Thanks for the note. I agree that a new release is long overdue. I am currently traveling until September, but I will put that onto my todo list for once I am back. Hoping to get to it some time early September