Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions doc/users/next_whats_new/diverging_colormaps.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Dark-mode diverging colormaps
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Three diverging colormaps have been added: "berlin", "managua", and "vanimo".
They are dark-mode diverging colormaps, with minimum lightness at the center,
and maximum at the extremes. These are taken from F. Crameri's Scientific
colour maps version 8.0.1 (DOI: https://doi.org/10.5281/zenodo.1243862).


.. plot::
:include-source: true
:alt: Example figures using "imshow" with dark-mode diverging colormaps on positive and negative data. First panel: "berlin" (blue to red with a black center); second panel: "managua" (orange to cyan with a dark purple center); third panel: "vanimo" (pink to green with a black center).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't lint rst files, but pretty sure this should be wrapped. I think as long as you indent the plot directive should still be OK.

Copy link
Contributor Author

@martinosorb martinosorb Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure whether breaking the line would send me out of the alt variable. I checked the previous what's new files and they seem to go on without breaking the line: https://raw.githubusercontent.com/matplotlib/matplotlib/ed56f95cb6f5b54525687dabbb0e660bafec4d94/doc/users/prev_whats_new/whats_new_3.9.0.rst; so I kept the same style.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure either, and maybe it was done that way on purpose. But if not, then it would be nice to have wrapping

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I was unable to compile the docs locally due to some dependency issues, so I cannot check. Sorry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats why we have CI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That didn't work, I reverted.


import numpy as np
import matplotlib.pyplot as plt

vals = np.linspace(-5, 5, 100)
x, y = np.meshgrid(vals, vals)
img = np.sin(x*y)

_, ax = plt.subplots(1, 3)
ax[0].imshow(img, cmap=plt.cm.berlin)
ax[1].imshow(img, cmap=plt.cm.managua)
ax[2].imshow(img, cmap=plt.cm.vanimo)
3 changes: 2 additions & 1 deletion galleries/examples/color/colormap_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
'hot', 'afmhot', 'gist_heat', 'copper']),
('Diverging', [
'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',
'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']),
'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic',
'berlin', 'managua', 'vanimo']),
('Cyclic', ['twilight', 'twilight_shifted', 'hsv']),
('Qualitative', [
'Pastel1', 'Pastel2', 'Paired', 'Accent',
Expand Down
8 changes: 7 additions & 1 deletion galleries/users_explain/colors/colormaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,15 @@ def plot_color_gradients(category, cmap_list):
# equal minimum :math:`L^*` values at opposite ends of the colormap. By these
# measures, BrBG and RdBu are good options. coolwarm is a good option, but it
# doesn't span a wide range of :math:`L^*` values (see grayscale section below).
#
# Berlin, Managua, and Vanimo are dark-mode diverging colormaps, with minimum
# lightness at the center, and maximum at the extremes. These are taken from
# F. Crameri's [scientific colour maps]_ version 8.0.1.

plot_color_gradients('Diverging',
['PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu',
'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic'])
'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic',
'berlin', 'managua', 'vanimo'])

# %%
# Cyclic
Expand Down Expand Up @@ -441,3 +446,4 @@ def plot_color_gradients(cmap_category, cmap_list):
# .. [colorblindness] http://www.color-blindness.com/
# .. [IBM] https://doi.org/10.1109/VISUAL.1995.480803
# .. [turbo] https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
# .. [scientific colour maps] https://doi.org/10.5281/zenodo.1243862
Loading
Loading