예제 #1
0
파일: test_misc.py 프로젝트: tbridel/salem
    def test_read_colormap(self):

        cl = utils.read_colormap('topo') * 256
        assert_allclose(cl[4, :], (177, 242, 196))
        assert_allclose(cl[-1, :], (235, 233, 235))

        cl = utils.read_colormap('dem') * 256
        assert_allclose(cl[4, :], (153, 100, 43))
        assert_allclose(cl[-1, :], (255, 255, 255))
예제 #2
0
    def test_read_colormap(self):

        cl = utils.read_colormap("topo") * 256
        assert_allclose(cl[4, :], (177, 242, 196))
        assert_allclose(cl[-1, :], (235, 233, 235))

        cl = utils.read_colormap("dem") * 256
        assert_allclose(cl[4, :], (153, 100, 43))
        assert_allclose(cl[-1, :], (255, 255, 255))
예제 #3
0
def get_cmap(cmap='viridis'):
    """Get a colormap from mpl, and also those defined by Salem.

    Currently we have: topo, dem, nrwc

    see https://github.com/fmaussion/salem-sample-data/tree/master/colormaps
    """

    try:
        return plt.get_cmap(cmap)
    except ValueError:
        cl = utils.read_colormap(cmap)
        return LinearSegmentedColormap.from_list(cmap, cl, N=256)
예제 #4
0
파일: graphics.py 프로젝트: fmaussion/salem
def get_cmap(cmap='viridis'):
    """Get a colormap from mpl, and also those defined by Salem.

    Currently we have: topo, dem, nrwc

    see https://github.com/fmaussion/salem-sample-data/tree/master/colormaps
    """

    try:
        return plt.get_cmap(cmap)
    except ValueError:
        cl = utils.read_colormap(cmap)
        return LinearSegmentedColormap.from_list(cmap, cl, N=256)