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

truncate_colormap parameter n isn't working as intended #124

Closed
kafitzgerald opened this issue May 5, 2023 · 0 comments · Fixed by #125
Closed

truncate_colormap parameter n isn't working as intended #124

kafitzgerald opened this issue May 5, 2023 · 0 comments · Fixed by #125
Assignees
Labels
bug Something isn't working

Comments

@kafitzgerald
Copy link
Collaborator

While I was updating truncate_colormap in viz, I noticed the parameter n wasn't working as intended. It would need to be specified as a parameter in mpl.colors.LinearSegmentedColormap.from_list rather than in np.linspace in order to specify the number of color values in the new colormap.

I thought maybe this was related to a change in matplotlib, but that doesn't appear to be the case.

Interestingly there are workaround(s) for this in the examples gallery. For example, in NCL_vector_4.py the colormap is truncated with n=16, but this doesn't work so then get_cmap is used to re-register it and give it 16 levels as desired or when using contourf the number of levels is assigned so it doesn't matter that truncate_colormap doesn't work as intended.

We should probably also clean up the colormap registration and deprecated colormap functions in examples. I'll log an issue over there.

@kafitzgerald kafitzgerald added the bug Something isn't working label May 5, 2023
@kafitzgerald kafitzgerald self-assigned this May 6, 2023
kafitzgerald added a commit to kafitzgerald/geocat-viz that referenced this issue May 6, 2023
Update truncate_colormap to use new matplotlib colormap registration to partially address issues NCAR#112 and NCAR#104.

Update truncate_colormap to actually return a colormap with n color segments to address issue NCAR#124.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant