8000 DOC: get rid of matplotlib DeprecationWarning in plot_cluster_iris.py… · thomasjpfan/scikit-learn@ae9483d · GitHub
[go: up one dir, main page]

Skip to content

Commit ae9483d

Browse files
nathansquanthomasjpfan
authored andcommitted
DOC: get rid of matplotlib DeprecationWarning in plot_cluster_iris.py (scikit-learn#22594)
1 parent 06273c1 commit ae9483d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/cluster/plot_cluster_iris.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import matplotlib.pyplot as plt
2424

2525
# Though the following import is not directly being used, it is required
26-
# for 3D projection to work
27-
from mpl_toolkits.mplot3d import Axes3D
26+
# for 3D projection to work with matplotlib < 3.2
27+
import mpl_toolkits.mplot3d # noqa: F401
2828

2929
from sklearn.cluster import KMeans
3030
from sklearn import datasets
@@ -45,7 +45,8 @@
4545
titles = ["8 clusters", "3 clusters", "3 clusters, bad initialization"]
4646
for name, est in estimators:
4747
fig = plt.figure(fignum, figsize=(4, 3))
48-
ax = Axes3D(fig, rect=[0, 0, 0.95, 1], elev=48, azim=134)
48+
ax = fig.add_subplot(111, projection="3d", elev=48, azim=134)
49+
ax.set_position([0, 0, 0.95, 1])
4950
est.fit(X)
5051
labels = est.labels_
5152

@@ -63,7 +64,8 @@
6364

6465
# Plot the ground truth
6566
fig = plt.figure(fignum, figsize=(4, 3))
66-
ax = Axes3D(fig, rect=[0, 0, 0.95, 1], elev=48, azim=134)
67+
ax = fig.add_subplot(111, projection="3d", elev=48, azim=134)
68+
ax.set_position([0, 0, 0.95, 1])
6769

6870
for name, label in [("Setosa", 0), ("Versicolour", 1), ("Virginica", 2)]:
6971
ax.text3D(

0 commit comments

Comments
 (0)
0