Fix pdf doc generation
Use 4 plots instead of one so that unsupervised_learning.rst can show png separately.
Partially reverts Minor changes for consistent labeling.
@@ -39,17 +39,16 @@ iris = datasets.load_iris()
X = iris.data
y = iris.target
-estimators = {'k_means_iris_3': KMeans(n_clusters=3),
- 'k_means_iris_8': KMeans(n_clusters=8),
- 'k_means_iris_bad_init': KMeans(n_clusters=3, n_init=1,
- init='random')}
+estimators = [('k_means_iris_8', KMeans(n_clusters=8)),
+ ('k_means_iris_3', KMeans(n_clusters=3)),
+ ('k_means_iris_bad_init', KMeans(n_clusters=3, n_init=1,
+ init='random'))]
-fig = plt.figure(figsize=(8, 6))
fignum = 1
-titles = ['3 clusters', '8 clusters', '3 clusters, bad initialization']
-for name, est in estimators.items():
- ax = plt.subplot(2, 2, fignum, projection='3d',
- elev=48, azim=134)
+titles = ['8 clusters', '3 clusters', '3 clusters, bad initialization']
+for name, est in estimators:
+ fig = plt.figure(fignum, figsize=(4, 3))
+ ax = Axes3D(fig, rect=[0, 0, .95, 1], elev=48, azim=134)
est.fit(X)
labels = est.labels_
@@ -67,8 +66,9 @@ for name, est in estimators.items():
fignum = fignum + 1
# Plot the ground truth
-ax = plt.subplot(2, 2, 4, projection='3d',
- elev=48, azim=134)
+fig = plt.figure(fignum, figsize=(4, 3))
+ax = Axes3D(fig, rect=[0, 0, .95, 1], elev=48, azim=134)
+
for name, label in [('Setosa', 0),
('Versicolour', 1),
('Virginica', 2)]:
@@ -90,5 +90,4 @@ ax.set_zlabel('Petal length')
ax.set_title('Ground Truth')
ax.dist = 12
-fig.tight_layout()
fig.show()
