.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_additional_cmap.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_additional_cmap.py: ================================= Get additional color palettes ================================= I created a class called `CommunityPalette` for accessing those pretty color palettes that are widely seen in oceanography but not directly available in Python. This can be from Ocean Data View (ODV), NCL, Ferret, etc. In this example, I will show these available color palettes in the `CommunityPalette` class. But the majority of them is from Ferret (Thank the Ferret community for making this open sourced), which can be found in https://ferret.pmel.noaa.gov/Ferret/faq/ferret-color-palettes .. GENERATED FROM PYTHON SOURCE LINES 13-45 .. image-sg:: /auto_examples/images/sphx_glr_plot_additional_cmap_001.png :alt: scientific_batlow, scientific_imola, my_rainbow2, kovesi_rainbow, cspace_BlRd, BlGrYeOrReVi, Section, WtBuGnYlRd, my_rainbow, colorcet_r_bgyr, scientific_vik, scientific_bam, ukiyoe, scientific_cork, BuGd, tol_rainbow, BuGr, r_terrain, Zissou1, parula, ODV, w5m4 :srcset: /auto_examples/images/sphx_glr_plot_additional_cmap_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from cgeniepy.plot import CommunityPalette def plot_colormaps(cmaps): ncols = 4 nrows = int(np.ceil(len(cmaps) / ncols)) fig, axes = plt.subplots(nrows, ncols, figsize=(15, nrows)) for i, cmap_name in enumerate(cmaps): row = i // ncols col = i % ncols ax = axes[row, col] if nrows > 1 else axes[col] # Create a gradient image using the colormap gradient = np.linspace(0, 1, 256).reshape(1, -1) ax.imshow(gradient, aspect='auto', cmap=CommunityPalette().get_palette(cmap_name)) ax.set_title(cmap_name, fontsize=14, fontweight='bold') ax.axis('off') ## remove the unused axes for i in range(len(cmaps), ncols * nrows): row = i // ncols col = i % ncols fig.delaxes(axes[row, col]) plt.tight_layout() # List of colormaps from cgeniepy cmaps_list = CommunityPalette().avail_palettes(show_ferret_data=False) plot_colormaps(cmaps_list) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.446 seconds) .. _sphx_glr_download_auto_examples_plot_additional_cmap.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_additional_cmap.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_additional_cmap.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_additional_cmap.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_