Esempio n. 1
0
 def test_default(self):
     create_cmap_overview()
Esempio n. 2
0
 def test_custom_cmaps_list_no_types(self):
     create_cmap_overview([cmrcm.rainforest], use_types=0)
     create_cmap_overview(['cmr.rainforest'], use_types=0)
Esempio n. 3
0
                bbox_inches='tight',
                pad_inches=0)
    plt.close(fig)

    # Create txt-file with colormap data
    np.savetxt("cm_{0}.txt".format(name), rgb, fmt='%.8e')

    # Create txt-file with 8-bit colormap data
    rgb_8bit = np.rint(rgb * 255)
    np.savetxt("{0}/{0}_8bit.txt".format(name), rgb_8bit, fmt='%i')

    # Load in all colormaps currently defined
    import_cmaps('.')

    # Make new colormap overview
    create_cmap_overview(savefig='cmap_overview.png', sort='lightness')
    create_cmap_overview(savefig=path.join(docs_dir, 'images',
                                           'cmap_overview.png'),
                         sort='lightness')
    create_cmap_overview(cmap_d.keys(),
                         plot_profile=True,
                         sort='lightness',
                         savefig=path.join(docs_dir, 'images',
                                           'mpl_cmaps.png'))

    # Make string with the docs entry
    docs_entry = dedent("""
        .. _{0}:

        {0}
        {1}
Esempio n. 4
0
                dpi=200,
                bbox_inches='tight',
                pad_inches=0)
    plt.close(fig)

    # Create txt-file with colormap data
    np.savetxt("cm_{0}.txt".format(name), cmap_mod.cm_data)

    # Delete the created __pycache__ in the loaded cmap module
    shutil.rmtree("{0}/__pycache__".format(name), ignore_errors=True)

    # Load in all colormaps currently defined
    import_cmaps('.')

    # Make new colormap overview
    create_cmap_overview(savefig='cmap_overview.png')

    # Make string with the docs entry and print it
    docs_entry = dedent("""
        {0}
        {2}
        .. figure:: ../../../cmasher/colormaps/{1}/{1}.png
            :alt: Visual representation of the *{1}* colormap.
            :width: 100%
            :align: center
            :name: {1}_cmap

        .. figure:: ../../../cmasher/colormaps/{1}/{1}_viscm.png
            :alt: Statistics of the *{1}* colormap.
            :width: 100%
            :align: center
Esempio n. 5
0
 def test_mpl_cmaps_names(self):
     create_cmap_overview(mplcm.cmap_d.keys(), sort='lightness')
Esempio n. 6
0
 def test_mpl_cmaps_names(self):
     create_cmap_overview(mpl_cmaps, sort='lightness')
Esempio n. 7
0
 def test_no_grayscale(self):
     create_cmap_overview([cmrcm.rainforest], show_grayscale=False)
Esempio n. 8
0
 def test_custom_cmaps_dict(self):
     create_cmap_overview({
         'test1': [cmrcm.rainforest],
         'test2': ['cmr.rainforest']
     })
Esempio n. 9
0
 def test_lightness_profiles(self):
     create_cmap_overview(mpl_cmaps, plot_profile=True)
Esempio n. 10
0
 def test_dark_mode(self):
     create_cmap_overview([cmrcm.rainforest], dark_mode=True)
Esempio n. 11
0
    # Create txt-file with colormap data
    np.savetxt("cm_{0}.txt".format(name), rgb, fmt='%.8f')

    # Create txt-file with normalized colormap data
    np.savetxt("{0}/{0}_norm.txt".format(name), rgb, fmt='%.8f')

    # Create txt-file with 8-bit colormap data
    rgb_8bit = np.rint(rgb * 255)
    np.savetxt("{0}/{0}_8bit.txt".format(name), rgb_8bit, fmt='%i')

    # Create txt-file with HEX colormap data
    rgb_hex = np.apply_along_axis((lambda x: to_hex(x).upper()), 1, rgb)
    np.savetxt("{0}/{0}_hex.txt".format(name), rgb_hex, fmt="%s")

    # Make new colormap overview
    create_cmap_overview(savefig='cmap_overview.png', sort='lightness')
    create_cmap_overview(savefig=path.join(docs_dir, 'images',
                                           'cmap_overview.png'),
                         sort='lightness')
    create_cmap_overview(plt.colormaps(),
                         plot_profile=True,
                         sort='lightness',
                         savefig=path.join(docs_dir, 'images',
                                           'mpl_cmaps.png'))
    create_cmap_app_overview()

    # Make string with the docs entry
    docs_entry = dedent("""
        .. _{0}:

        {0}
Esempio n. 12
0
import matplotlib.cm as cm
import cmasher as cmr
from cmasher.utils import create_cmap_overview
import colorcet as cc
from bipolar import bipolar, hotcold

# Full range of bipolar plots
cmaps = []
for n in (0.0, 0.2, 0.4, 0.6, 0.8, 1.0):
    cmap = bipolar(neutral=n)
    cmap.name = f'bipolar {n}'
    cmaps.append(cmap)

create_cmap_overview(cmaps, use_types=False, savefig='bipolar range.png',
                     plot_profile=True, sort=None, title="bipolar() range")

# Full range of hotcold plots
cmaps = []
for n in (0.0, 0.2, 0.4, 0.6, 0.8, 1.0):
    cmap = hotcold(neutral=n)
    cmap.name = f'hotcold {n}'
    cmaps.append(cmap)

create_cmap_overview(cmaps, use_types=False, savefig='hotcold range.png',
                     plot_profile=True, sort=None, title="hotcold() range")

# Bipolar vs other dark-centered hot-cold maps
cmaps = [('bipolar 0.0', bipolar(neutral=0)),
         ('hotcold 0.0', hotcold(neutral=0)),
         ('cmr.iceburn', cmr.iceburn),
         ('cmr.redshift', cmr.redshift),
Esempio n. 13
0
 def test_lightness_profiles(self):
     create_cmap_overview(mplcm.cmap_d.keys(), plot_profile=True)
Esempio n. 14
0
 def test_custom_cmaps_list_cat(self):
     create_cmap_overview(['cmr.rainforest'])
Esempio n. 15
0
 def test_list_no_types(self):
     create_cmap_overview([cmrcm.rainforest], use_types=0, sort='lightness')
     create_cmap_overview(['cmr.rainforest', 'cmr.rainforest_r'],
                          use_types=0, title=0)
Esempio n. 16
0
 def test_custom_cmaps_mpl(self):
     create_cmap_overview(mplcm.cmap_d.values())
Esempio n. 17
0
 def test_mpl_cmaps_objs(self):
     cmaps = map(mplcm.get_cmap, mpl_cmaps)
     create_cmap_overview(cmaps, sort='alphabetical')
Esempio n. 18
0
 def test_savefig(self):
     create_cmap_overview(savefig="test.png")
     assert path.exists("./test.png")
Esempio n. 19
0
 def test_mpl_cmaps_objs(self):
     create_cmap_overview(mplcm.cmap_d.values(), sort='alphabetical')