Skip to content

Commit 7c0ebbc

Browse files
saiwing-yeungagramfort
authored andcommitted
FIX does not draw the ellipse! scikit-learn#6640 (scikit-learn#6757)
* FIX does not draw the ellipse! scikit-learn#6640 * Give ellipses a higher z-order, yellow border, and thicker border. * Add an alpha level to the markers so that it is easier to tell how many there are. * Change false positive to asterisks so that they have similar sizes as the true positives. * Fix line too long issue
1 parent c5c2b37 commit 7c0ebbc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

examples/classification/plot_lda_qda.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,19 @@ def plot_data(lda, X, y, y_pred, fig_index):
6868
X0_tp, X0_fp = X0[tp0], X0[~tp0]
6969
X1_tp, X1_fp = X1[tp1], X1[~tp1]
7070

71+
alpha = 0.5
72+
7173
# class 0: dots
72-
plt.plot(X0_tp[:, 0], X0_tp[:, 1], 'o', color='red')
73-
plt.plot(X0_fp[:, 0], X0_fp[:, 1], '.', color='#990000') # dark red
74+
plt.plot(X0_tp[:, 0], X0_tp[:, 1], 'o', alpha=alpha,
75+
color='red')
76+
plt.plot(X0_fp[:, 0], X0_fp[:, 1], '*', alpha=alpha,
77+
color='#990000') # dark red
7478

7579
# class 1: dots
76-
plt.plot(X1_tp[:, 0], X1_tp[:, 1], 'o', color='blue')
77-
plt.plot(X1_fp[:, 0], X1_fp[:, 1], '.', color='#000099') # dark blue
80+
plt.plot(X1_tp[:, 0], X1_tp[:, 1], 'o', alpha=alpha,
81+
color='blue')
82+
plt.plot(X1_fp[:, 0], X1_fp[:, 1], '*', alpha=alpha,
83+
color='#000099') # dark blue
7884

7985
# class 0 and 1 : areas
8086
nx, ny = 200, 100
@@ -104,7 +110,8 @@ def plot_ellipse(splot, mean, cov, color):
104110
angle = 180 * angle / np.pi # convert to degrees
105111
# filled Gaussian at 2 standard deviation
106112
ell = mpl.patches.Ellipse(mean, 2 * v[0] ** 0.5, 2 * v[1] ** 0.5,
107-
180 + angle, color=color)
113+
180 + angle, facecolor=color, edgecolor='yellow',
114+
linewidth=2, zorder=2)
108115
ell.set_clip_box(splot.bbox)
109116
ell.set_alpha(0.5)
110117
splot.add_artist(ell)

0 commit comments

Comments
 (0)