Exemplo n.º 1
0
def wrap_viscm(cmap, dpi=100, saveplot=False):
    '''Evaluate goodness of colormap using perceptual deltas.

    :param cmap: Colormap instance.
    :param dpi=100: dpi for saved image.

    '''

    from viscm import viscm

    viscm(cmap)
    fig = plt.gcf()
    fig.set_size_inches(22, 10)
    plt.show()

    if saveplot:
        fig.savefig('figures/eval_' + cmap.name + '.png', bbox_inches='tight', dpi=dpi)
        fig.savefig('figures/eval_' + cmap.name + '.pdf', bbox_inches='tight', dpi=dpi)
Exemplo n.º 2
0
def wrap_viscm(cmap, dpi=100, saveplot=False):
    """Evaluate goodness of colormap using perceptual deltas.

    :param cmap: Colormap instance.
    :param dpi=100: dpi for saved image.
    :param saveplot=False: Whether to save the plot or not.

    """

    from viscm import viscm

    viscm(cmap)
    fig = plt.gcf()
    fig.set_size_inches(22, 10)
    plt.show()

    if saveplot:
        fig.savefig("figures/eval_" + cmap.name + ".png", bbox_inches="tight", dpi=dpi)
        fig.savefig("figures/eval_" + cmap.name + ".pdf", bbox_inches="tight", dpi=dpi)
    [0.72342267, 0.90357961, 0.23341551], [0.73886245, 0.90385588, 0.23691527],
    [0.75384169, 0.90414168, 0.2422736], [0.76828873, 0.90447092, 0.24933693],
    [0.78221676, 0.90485188, 0.25792794], [0.79558008, 0.90531303, 0.26782053],
    [0.80842177, 0.90585258, 0.27883421], [0.8207006, 0.90649867, 0.29072839],
    [0.83248598, 0.90723837, 0.30337614], [0.84378474, 0.90808079, 0.31661371],
    [0.85460273, 0.90903543, 0.33028474], [0.86499688, 0.91008983, 0.3443259],
    [0.87499154, 0.91124343, 0.35865065], [0.88461129, 0.91249469, 0.3731879],
    [0.89387855, 0.91384221, 0.38787579], [0.90281044, 0.9152864, 0.4026516],
    [0.9114428, 0.91681782, 0.41750661], [0.91979668, 0.91843305, 0.43241222],
    [0.9278919, 0.92012856, 0.44734592], [0.93574701, 0.9219008, 0.46229025],
    [0.94337929, 0.92374622, 0.47723183], [0.95080035, 0.92566398, 0.49214548],
    [0.95802315, 0.92765211, 0.50701436], [0.96506661, 0.92970447, 0.52184916],
    [0.97194366, 0.93181788, 0.53664677], [0.97866617, 0.93398929, 0.55140545],
    [0.98524501, 0.93621585, 0.56612453], [0.99169013, 0.93849488, 0.58080418]
]

test_cm = LinearSegmentedColormap.from_list(__file__, cm_data)

if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from viscm import viscm
        viscm(test_cm)
    except ImportError:
        print("viscm not found, falling back on simple display")
        plt.imshow(
            np.linspace(0, 100, 256)[None, :], aspect='auto', cmap=test_cm)
    plt.show()
Exemplo n.º 4
0
           [0.9449571429, 0.7261142857, 0.2886428571],
           [0.9738952381, 0.7313952381, 0.266647619],
           [0.9937714286, 0.7454571429, 0.240347619],
           [0.9990428571, 0.7653142857, 0.2164142857],
           [0.9955333333, 0.7860571429, 0.196652381],
           [0.988,        0.8066,       0.1793666667],
           [0.9788571429, 0.8271428571, 0.1633142857],
           [0.9697,       0.8481380952, 0.147452381],
           [0.9625857143, 0.8705142857, 0.1309],
           [0.9588714286, 0.8949,       0.1132428571],
           [0.9598238095, 0.9218333333, 0.0948380952],
           [0.9661,       0.9514428571, 0.0755333333], 
           [0.9763,       0.9831,       0.0538]]

parula_map = LinearSegmentedColormap.from_list('parula', cm_data)
# For use of "viscm view"
test_cm = parula_map

if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from viscm import viscm
        viscm(parula_map)
    except ImportError:
        print("viscm not found, falling back on simple display")
        plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',
                   cmap=parula_map)
    plt.show()
Exemplo n.º 5
0
                 cmap], va='center', ha='left', fontsize=12)

    for ax in axes:
        ax.set_axis_off()

    buf = StringIO()
    try:
        plt.savefig(buf, format="png", dpi='figure')
        plt.close(fig)
        return buf.getvalue()
    finally:
        buf.close()


if __name__ == '__main__':
    import viscm
    import matplotlib.cm
    import sys

    for k, v in colormaps.iteritems():
        matplotlib.cm.register_cmap(name=k, cmap=v)

    maps = [i for i in colormaps]
    if len(sys.argv) > 1:
        maps = sys.argv[1:]

    for m in maps:
        v = viscm.viscm(m, uniform_space="CAM02-UCS")
        v.fig.set_size_inches(20, 12)
        v.fig.savefig(m + ".png")
Exemplo n.º 6
0
           [ 0.93997257, 0.04786426, 0.1344111 ],
           [ 0.94336796, 0.04991831, 0.12950803],
           [ 0.94675308, 0.05203472, 0.12446169],
           [ 0.95012726, 0.05421413, 0.11926072],
           [ 0.95349009, 0.05645569, 0.11388811],
           [ 0.95684173, 0.05875624, 0.10831624],
           [ 0.96018119, 0.06111767, 0.10252706],
           [ 0.96350801, 0.06353929, 0.09649019],
           [ 0.96682217, 0.06601885, 0.09016074],
           [ 0.97012287, 0.06855717, 0.08349422],
           [ 0.97340949, 0.07115419, 0.07642881],
           [ 0.97668194, 0.07380809, 0.06886982],
           [ 0.97993936, 0.07651969, 0.06070177],
           [ 0.98318108, 0.07928898, 0.05174878]]

hotwater = ListedColormap(cm_data, name=__file__)


if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from viscm import viscm
        viscm(hotwater)
    except ImportError:
        print("viscm not found, falling back on simple display")
        plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',
                   cmap=hotwater)
    plt.show()
Exemplo n.º 7
0
           [ 0.86478781, 0.09251486, 0.13201454],
           [ 0.86741167, 0.09062789, 0.12678153],
           [ 0.87003044, 0.08870972, 0.12140973],
           [ 0.87264415, 0.0867589 , 0.11588389],
           [ 0.8752528 , 0.08477388, 0.1101858 ],
           [ 0.87785643, 0.08275293, 0.1042935 ],
           [ 0.88045505, 0.08069421, 0.0981801 ],
           [ 0.8830487 , 0.07859568, 0.09181218],
           [ 0.88563739, 0.07645512, 0.0851474 ],
           [ 0.88822115, 0.07427006, 0.0781309 ],
           [ 0.89080001, 0.07203779, 0.07068959],
           [ 0.89337398, 0.06975531, 0.06272268],
           [ 0.89594311, 0.06741927, 0.05408478],
           [ 0.8985074 , 0.06502592, 0.04455319]]

coldhot = ListedColormap(cm_data, name=__file__)


if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from viscm import viscm
        viscm(coldhot)
    except ImportError:
        print("viscm not found, falling back on simple display")
        plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',
                   cmap=coldhot)
    plt.show()
Exemplo n.º 8
0
           [0.42892, 0.062415, 0.026522],      
           [0.42215, 0.056832, 0.026954],      
           [0.41544, 0.051116, 0.027378],      
           [0.40877, 0.045352, 0.02779],      
           [0.40213, 0.039448, 0.028189],      
           [0.39556, 0.033385, 0.02857],      
           [0.38902, 0.027844, 0.028932],      
           [0.3825, 0.022586, 0.029271],      
           [0.37603, 0.017608, 0.029583],      
           [0.36958, 0.01289, 0.029866],      
           [0.36316, 0.0082428, 0.030115],      
           [0.35679, 0.0040345, 0.030327],      
           [0.35042, 6.1141e-05, 0.030499]]      
      
vik_map = LinearSegmentedColormap.from_list('vik', cm_data)      
# For use of "viscm view"      
test_cm = vik_map      
      
if __name__ == "__main__":      
    import matplotlib.pyplot as plt      
    import numpy as np      
      
    try:      
        from viscm import viscm      
        viscm(vik_map)      
    except ImportError:      
        print("viscm not found, falling back on simple display")      
        plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',      
                   cmap=vik_map)      
    plt.show()      
Exemplo n.º 9
0
           [0.3041, 0.30402, 0.1313], [0.29685, 0.29681, 0.12539],
           [0.28962, 0.28962, 0.11954], [0.28244, 0.28249, 0.11379],
           [0.27527, 0.27539, 0.10806], [0.26813, 0.26833, 0.10249],
           [0.26105, 0.26133, 0.096944], [0.25399, 0.2544, 0.091611],
           [0.24697, 0.2475, 0.086229], [0.23998, 0.24063, 0.081071],
           [0.23304, 0.23386, 0.075946], [0.22617, 0.22715, 0.071044],
           [0.2193, 0.22051, 0.06617], [0.21249, 0.2139, 0.061401],
           [0.20574, 0.20737, 0.056843], [0.19905, 0.20087, 0.051883],
           [0.19252, 0.19451, 0.046707], [0.1861, 0.18816, 0.041106],
           [0.17975, 0.18183, 0.035101], [0.17354, 0.17561, 0.028925],
           [0.16747, 0.16948, 0.022922], [0.16153, 0.16336, 0.016908],
           [0.15569, 0.15726, 0.01067], [0.15, 0.15126, 0.0046261]]

broc_map = LinearSegmentedColormap.from_list('broc', cm_data)
# For use of "viscm view"
test_cm = broc_map

if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from viscm import viscm
        viscm(broc_map)
    except ImportError:
        print("viscm not found, falling back on simple display")
        plt.imshow(np.linspace(0, 100, 256)[None, :],
                   aspect='auto',
                   cmap=broc_map)
    plt.show()
Exemplo n.º 10
0
           [9.70532932e-01, 8.87896125e-01, 1.45918663e-01],
           [9.68443477e-01, 8.94563989e-01, 1.47014438e-01],
           [9.66271225e-01, 9.01249365e-01, 1.48179639e-01],
           [9.64021057e-01, 9.07950379e-01, 1.49370428e-01],
           [9.61681481e-01, 9.14672479e-01, 1.50520343e-01],
           [9.59275646e-01, 9.21406537e-01, 1.51566019e-01],
           [9.56808068e-01, 9.28152065e-01, 1.52409489e-01],
           [9.54286813e-01, 9.34907730e-01, 1.52921158e-01],
           [9.51726083e-01, 9.41670605e-01, 1.52925363e-01],
           [9.49150533e-01, 9.48434900e-01, 1.52177604e-01],
           [9.46602270e-01, 9.55189860e-01, 1.50327944e-01],
           [9.44151742e-01, 9.61916487e-01, 1.46860789e-01],
           [9.41896120e-01, 9.68589814e-01, 1.40955606e-01],
           [9.40015097e-01, 9.75158357e-01, 1.31325517e-01]]

test_cm = LinearSegmentedColormap.from_list(__file__, cm_data)

if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from viscm import viscm
        viscm(test_cm)
    except ImportError:
        print("viscm not found, falling back on simple display")
        plt.imshow(np.linspace(0, 100, 256)[None, :],
                   aspect='auto',
                   cmap=test_cm)
    plt.show()
Exemplo n.º 11
0
from matplotlib.colors import LinearSegmentedColormap

cm_data = [[0.0, 1.0, 0.0], [0.0, 0.5, 0.5], [0.0, 0.0, 1.0], [0.0, 0.5, 1.0],
           [0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 0.0, 1.0], [1.0, 0.0, 0.5],
           [1.0, 0.0, 0.0], [1.0, 0.5, 0.0], [1.0, 1.0, 0.0]]

gbcwpry_map = LinearSegmentedColormap.from_list('gbcwpry', cm_data)
# For use of "viscm view"
test_cm = gbcwpry_map

if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from viscm import viscm
        viscm(gbcwpry_map)
    except ImportError:
        print("viscm not found, falling back on simple display")
        plt.imshow(np.linspace(0, 100, 256)[None, :],
                   aspect='auto',
                   cmap=gbcwpry_map)
    plt.show()