.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_cmap.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_cmap.py: Plotting Colormaps ====================== Show all colormaps in kkpy .. GENERATED FROM PYTHON SOURCE LINES 7-44 .. image:: /auto_examples/images/sphx_glr_plot_cmap_001.png :alt: plot cmap :class: sphx-glr-single-img .. code-block:: default :lineno-start: 8 import kkpy import matplotlib as mpl import matplotlib.pyplot as plt import inspect # Get all available cmaps def available_functions(module): func_list_with_underscore = [x.__name__ for x in module.__dict__.values() if inspect.isfunction(x)] func_list = [x for x in func_list_with_underscore if not x.startswith('_')] return func_list cm_list = available_functions(kkpy.cm) # Get labels for each cmap labels = [f'kkpy.cm.{x}()' for x in cm_list] # Draw cmaps fig = plt.figure(figsize=(15,len(cm_list)), dpi=250) gs = fig.add_gridspec(len(cm_list), 1, hspace=3.5) for i_c, cm in enumerate(cm_list): # for each cmap cmap = getattr(kkpy.cm, cm)() ax = plt.subplot(gs[i_c]) # cmap and norm are usually used in plt.pcolormesh() # ticks can be used in plt.colorbar() cb = mpl.colorbar.ColorbarBase(ax, cmap=cmap['cmap'], norm=cmap['norm'], ticks=cmap['ticks'], orientation='horizontal') cb.set_label(labels[i_c]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.011 seconds) **Estimated memory usage:** 10 MB .. _sphx_glr_download_auto_examples_plot_cmap.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/Kwonil-Kim/kkpy/gh-pages?filepath=notebooks/auto_examples/plot_cmap.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cmap.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cmap.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_