Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`cmocean.tools.print_colormaps` snippet in the docs raises an error

Open
#118 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
documentation

Research direction

Start with the capabilities example linked in the issue and cmocean/tools.py around line 23; run the documented snippet and inspect how print_colormaps handles its input and writes output. Update the documentation example so it no longer raises the reported error, and clarify or verify where its output files should appear.

Written by the indexing model from the issue text.

Description

Hello! I love your work, this is my favorite set of colormaps.

Today I wanted to run some code from the docs:

import cmocean

cmaps = cmocean.cm.cmap_d
cmocean.tools.print_colormaps(cmaps)

and it produces the following exception and traceback:

Traceback (most recent call last):
  File "/home/mfisher/Projects/_test/extend-colormaps-js/test.py", line 4, in <module>
    cmocean.tools.print_colormaps(cmaps)
  File "/home/mfisher/Projects/_test/extend-colormaps-js/.pixi/envs/default/lib/python3.12/site-packages/cmocean/tools.py", line 25, in print_colormaps
    rgbtemp = cmap(np.linspace(0, 1, N))[np.newaxis, :, :3][0]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object is not callable

The issue appears to be here:

https://github.com/matplotlib/cmocean/blob/59c35002c3aa5296b65d9646e52604c627441eb6/cmocean/tools.py#L23

We loop over the cmaps object, which is a dictionary of colormap name keys to colormap object values in this invocation, but the function expects the object to be a list of colormap objects.

So the docs could be updated to:

import cmocean

cmaps = cmocean.cm.cmap_d
cmocean.tools.print_colormaps(cmaps.values())

But after running this code I don't see the output files!

Dominant language
Python
Stars
269
Forks
54
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from matplotlib/cmocean

All issues in matplotlib/cmocean

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.