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

Colormap centering & norms #1740

Closed
Phlya opened this issue May 13, 2019 · 1 comment
Closed

Colormap centering & norms #1740

Phlya opened this issue May 13, 2019 · 1 comment

Comments

@Phlya
Copy link

Phlya commented May 13, 2019

There is a beautiful way to center a colormap using seaborn in heatmap:

ax = sns.heatmap(np.linspace(-2, 5, 100).reshape((10, 10)), cmap='coolwarm', center=0, square=True)
ax.axis('off')

image

Unfortunately, there is not tool that does it in matplotlib itself. Is there a way to just get a colormap like this with specific vmin, center and vmax to use in matplotlib functions?

Also, is there a way to apply e.g. a LogNorm to the plot made with heatmap?

@mwaskom
Copy link
Owner

mwaskom commented May 13, 2019

You can't really get "just a colormap .. with a specific vmin, center, and vmax" because the limits aren't properties of the colormap, they're properties of the visualization that uses it. But you could use/adapt this: https://gist.github.com/phobson/7916777

To answer your second question, you can use the norm= argument from pcolormesh, but it will probably interact in unpredictable ways with the centering.

@mwaskom mwaskom closed this as completed May 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants