rasbt/python-machine-learning-book-2nd-edition

plot_decision_regions

Closed this issue · 5 comments

if test_idx:
    X_test, y_test = X[test_idx, :], y[test_idx]
    plt.scatter(X_test[:, 0], X_test[:, 1],
                alpha=1.0, linewidths=1, marker='o',
                s=55, label='test set')

in book, with c='', is not work

rasbt commented

Hm, that's weird. In worked fine when I ran it. Which version of matplotlib are you using and what error/issue are you observing if you set c='"" like in the book?

plt.scatter(X_test[:, 0], X_test[:, 1],
            c='', edgecolor='black', alpha=1.0,
            linewidth=1, marker='o',
            s=100, label='test set')

latest anaconda on macos

rasbt commented

Would be nice if you could provide more info. I am also using the latest matplotlib installation via conda on macOS (matplotlib v. 2.1.1).

Next to the matplotlib version, what kind of error are you getting or how do the resulting plots look like?

if test_idx:
    print('test_idx')
    X_test, y_test = X[test_idx, :], y[test_idx]
    plt.scatter(X_test[:, 0], X_test[:, 1], c='',
                alpha=1.0, linewidths=1, marker='o',
                s=55, label='test set')

i can't see test set , but when i remove c='', i can.
matplotlib.version is '2.0.2'

rasbt commented

Hm, this is weird. I ran this on both matplotlib 2.0.2 and matplotlib 2.1.2 just as it was printed in the book with c='' and can't reproduce this issue. What c='' is supposed to do is to remove the fill color, otherwise, you would have e.g., blue-colored dots.

I noticed a typo in your code though, you forgot to set edgecolor='black' and without it the circles would be invisible if you set c=''.

With edgecolor='black' you should see something like the following:

unknown

Hope this solves the issue :)