Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matplotlib.cm.spectral no longer exists #10761

Closed
jnothman opened this issue Mar 7, 2018 · 4 comments
Closed

matplotlib.cm.spectral no longer exists #10761

jnothman opened this issue Mar 7, 2018 · 4 comments
Labels
Documentation good first issue Easy with clear instructions to resolve help wanted

Comments

@jnothman
Copy link
Member

jnothman commented Mar 7, 2018

It was a deprecated alias for nipy_spectral (see matplotlib/matplotlib#7416). It seems to have been removed in the last release of matplotlib (2.2.0), causing some of our examples to fail.

@jnothman jnothman added Documentation good first issue Easy with clear instructions to resolve help wanted labels Mar 7, 2018
@jnothman
Copy link
Member Author

jnothman commented Mar 7, 2018

From the CircleCI logs:

Unexpected failing examples:
/home/circleci/project/examples/cluster/plot_coin_segmentation.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/cluster/plot_coin_segmentation.py", line 75, in <module>
    colors=[plt.cm.spectral(l / float(N_REGIONS))])
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'


/home/circleci/project/examples/cluster/plot_kmeans_silhouette_analysis.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/cluster/plot_kmeans_silhouette_analysis.py", line 98, in <module>
    color = cm.spectral(float(i) / n_clusters)
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'


/home/circleci/project/examples/cluster/plot_digits_agglomeration.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/cluster/plot_digits_agglomeration.py", line 57, in <module>
    interpolation='nearest', cmap=plt.cm.spectral)
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'


/home/circleci/project/examples/decomposition/plot_pca_iris.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/decomposition/plot_pca_iris.py", line 53, in <module>
    ax.scatter(X[:, 0], X[:, 1], X[:, 2], c=y, cmap=plt.cm.spectral,
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'

/home/circleci/project/examples/cluster/plot_digits_linkage.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/cluster/plot_digits_linkage.py", line 90, in <module>
    plot_clustering(X_red, X, clustering.labels_, "%s linkage" % linkage)
  File "/home/circleci/project/examples/cluster/plot_digits_linkage.py", line 66, in plot_clustering
    color=plt.cm.spectral(labels[i] / 10.),
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'


/home/circleci/project/examples/cluster/plot_agglomerative_clustering.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/cluster/plot_agglomerative_clustering.py", line 68, in <module>
    cmap=plt.cm.spectral)
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'


/home/circleci/project/examples/cluster/plot_kmeans_stability_low_dim_dense.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/cluster/plot_kmeans_stability_low_dim_dense.py", line 111, in <module>
    color = cm.spectral(float(k) / n_clusters, 1)
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'


/home/circleci/project/examples/cluster/plot_coin_ward_segmentation.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/cluster/plot_coin_ward_segmentation.py", line 66, in <module>
    colors=[plt.cm.spectral(l / float(n_clusters)), ])
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'

@divya-vakil
Copy link

I am also facing issue with the following PCA example:

http://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_iris.html

@jnothman
Copy link
Member Author

Sorry we have been slow to release

@CaiqueCoelho
Copy link

You can do this:
cmap = cm.get_cmap("Spectral")
colors = cmap(a / b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation good first issue Easy with clear instructions to resolve help wanted
Projects
None yet
Development

No branches or pull requests

3 participants