8000 DOC Improve the output of example plot_iris.py after matplotlib2.0 (#… · maskani-moh/scikit-learn@ad24ef0 · GitHub
[go: up one dir, main page]

Skip to content

Commit ad24ef0

Browse files
qinhanmin2014maskani-moh
authored andcommitted
DOC Improve the output of example plot_iris.py after matplotlib2.0 (scikit-learn#9541)
1 parent 2e44315 commit ad24ef0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

examples/tree/plot_iris.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# Parameters
2424
n_classes = 3
25-
plot_colors = "bry"
25+
plot_colors = "ryb"
2626
plot_step = 0.02
2727

2828
# Load data
@@ -44,23 +44,22 @@
4444
y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
4545
xx, yy = np.meshgrid(np.arange(x_min, x_max, plot_step),
4646
np.arange(y_min, y_max, plot_step))
47+
plt.tight_layout(h_pad=0.5, w_pad=0.5, pad=2.5)
4748

4849
Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
4950
Z = Z.reshape(xx.shape)
50-
cs = plt.contourf(xx, yy, Z, cmap=plt.cm.Paired)
51+
cs = plt.contourf(xx, yy, Z, cmap=plt.cm.RdYlBu)
5152

5253
plt.xlabel(iris.feature_names[pair[0]])
5354
plt.ylabel(iris.feature_names[pair[1]])
54-
plt.axis("tight")
5555

5656
# Plot the training points
5757
for i, color in zip(range(n_classes), plot_colors):
5858
idx = np.where(y == i)
5959
plt.scatter(X[idx, 0], X[idx, 1], c=color, label=iris.target_names[i],
60-
cmap=plt.cm.Paired)
61-
62-
plt.axis("tight")
60+
cmap=plt.cm.RdYlBu, edgecolor='black', s=15)
6361

6462
plt.suptitle("Decision surface of a decision tree using paired features")
65-
plt.legend()
63+
plt.legend(loc='lower right', borderpad=0, handletextpad=0)
64+
plt.axis("tight")
6665
plt.show()

0 commit comments

Comments
 (0)
0