DOC Improve the output of example plot_iris.py after matplotlib2.0
@@ -22,7 +22,7 @@ from sklearn.tree import DecisionTreeClassifier
# Parameters
n_classes = 3
-plot_colors = "bry"
+plot_colors = "ryb"
plot_step = 0.02
# Load data
@@ -44,23 +44,22 @@ for pairidx, pair in enumerate([[0, 1], [0, 2], [0, 3],
y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max, plot_step),
np.arange(y_min, y_max, plot_step))
+ plt.tight_layout(h_pad=0.5, w_pad=0.5, pad=2.5)
Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
- cs = plt.contourf(xx, yy, Z, cmap=plt.cm.Paired)
+ cs = plt.contourf(xx, yy, Z, cmap=plt.cm.RdYlBu)
plt.xlabel(iris.feature_names[pair[0]])
plt.ylabel(iris.feature_names[pair[1]])
- plt.axis("tight")
# Plot the training points
for i, color in zip(range(n_classes), plot_colors):
idx = np.where(y == i)
plt.scatter(X[idx, 0], X[idx, 1], c=color, label=iris.target_names[i],
- cmap=plt.cm.Paired)
-
- plt.axis("tight")
+ cmap=plt.cm.RdYlBu, edgecolor='black', s=15)
plt.suptitle("Decision surface of a decision tree using paired features")
-plt.legend()
+plt.legend(loc='lower right', borderpad=0, handletextpad=0)
+plt.axis("tight")
plt.show()
