示例#1
0
def awesome(rng, **traits):
    """
    Generator function for a Chaco color scale that has low-intensity contrast.
    """
    stream = pkg_resources.resource_stream(__name__, 'data/awesomecolormap.csv')
    return ColorMapper.from_palette_array(N.loadtxt(stream, delimiter=','),
        range=rng, **traits)
示例#2
0
def awesome(rng, **traits):
    """
    Generator function for a Chaco color scale that has low-intensity contrast.
    """
    return ColorMapper.from_palette_array(N.loadtxt(
        '../data/awesomecolormap.csv', delimiter=','),
                                          range=rng,
                                          **traits)
示例#3
0
 def test_alpha_palette(self):
     """ Create a colormap with a varying alpha channel from a palette array.
     """
     cm = ColorMapper.from_palette_array([[0.0,0.0,0.0,0.5],[1.0,1.0,1.0,1.0]])
     sd = {'alpha': [(0.0, 0.5, 0.5), (1.0, 1.0, 1.0)],
           'blue': [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)],
           'green': [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)],
           'red': [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)]}
     assert cm._segmentdata == sd
示例#4
0
    def chaco_gen(self):
        self.conn_mat = Plot(ArrayPlotData(imagedata=self.ds.adj_thresdiag))

        cm = ColorMapper.from_palette_array(
            self.ds.opts.connmat_map._pl(xrange(256)))
        self.conn_mat.img_plot('imagedata', name='connmatplot', colormap=cm)

        self.conn_mat.tools.append(ZoomTool(self.conn_mat))
        self.conn_mat.tools.append(PanTool(self.conn_mat))
        self.xa = ColorfulAxis(self.conn_mat, self.ds.node_colors, 'x')
        self.ya = ColorfulAxis(self.conn_mat, self.ds.node_colors, 'y')
        self.conn_mat.underlays = [self.xa, self.ya]
示例#5
0
文件: dataview.py 项目: aestrivex/cvu
    def chaco_gen(self): 
        self.conn_mat=Plot(ArrayPlotData(imagedata=self.ds.adj_thresdiag))

        cm=ColorMapper.from_palette_array(self.ds.opts.connmat_map._pl(
            xrange(256)))
        self.conn_mat.img_plot('imagedata',name='connmatplot',colormap=cm)

        self.conn_mat.tools.append(ZoomTool(self.conn_mat))
        self.conn_mat.tools.append(PanTool(self.conn_mat))
        self.xa=ColorfulAxis(self.conn_mat,self.ds.node_colors,'x')
        self.ya=ColorfulAxis(self.conn_mat,self.ds.node_colors,'y')
        self.conn_mat.underlays=[self.xa,self.ya]
示例#6
0
    def empty_gen(self):
        from chaco.api import Greys
        img = np.zeros((self.ds.nr_labels, self.ds.nr_labels))
        self.conn_mat = Plot(ArrayPlotData(imagedata=img))

        cm = ColorMapper.from_palette_array(
            self.ds.opts.connmat_map._pl(xrange(256)))
        self.conn_mat.img_plot('imagedata', name='connmatplot', colormap=cm)

        self.conn_mat.tools.append(ZoomTool(self.conn_mat))
        self.conn_mat.tools.append(PanTool(self.conn_mat))
        self.xa = ColorfulAxis(self.conn_mat, self.ds.node_colors, 'x')
        self.ya = ColorfulAxis(self.conn_mat, self.ds.node_colors, 'y')
        self.conn_mat.underlays = [self.xa, self.ya]
示例#7
0
文件: dataview.py 项目: aestrivex/cvu
    def empty_gen(self):
        from chaco.api import Greys
        img = np.zeros((self.ds.nr_labels,self.ds.nr_labels))
        self.conn_mat=Plot(ArrayPlotData(imagedata=img))

        cm=ColorMapper.from_palette_array(self.ds.opts.connmat_map._pl(
            xrange(256)))
        self.conn_mat.img_plot('imagedata',name='connmatplot',colormap=cm)

        self.conn_mat.tools.append(ZoomTool(self.conn_mat))
        self.conn_mat.tools.append(PanTool(self.conn_mat))
        self.xa=ColorfulAxis(self.conn_mat,self.ds.node_colors,'x')
        self.ya=ColorfulAxis(self.conn_mat,self.ds.node_colors,'y')
        self.conn_mat.underlays=[self.xa,self.ya]
示例#8
0
    def test_array_factory(self):
        """ Test that the array factory creates valid colormap. """

        colors = array([[0.0,0.0,0.0], [1.0,1.0,1.0]])
        cm = ColorMapper.from_palette_array(colors)
        cm.range = DataRange1D()

        ar = ArrayDataSource(array([0.0, 0.5, 1.0]))
        cm.range.add(ar)
        b = cm.map_screen(ar.get_data())
        cm.range.remove(ar)

        expected = array([0.0, 0.5, 1.0])

        self.assertTrue(allclose(ravel(b[:,:1]), expected, atol=0.02),
            "Array factory failed.  Expected %s.  Got %s" % (expected, b[:,:1]))

        return
示例#9
0
def isoluminant(rng, num_cycles=1, num_colors=256, reverse=False, **traits):
    """
    Generator function for a Chaco color scale that cycles through the hues
    @num_cycles times, while maintaining monotonic luminance (i.e., if it is
    printed in black and white, then it will be perceptually equal to a linear
    grayscale.

    Ported from the Matlab(R) code from: McNames, J. (2006). An effective color
    scale for simultaneous color and gray-scale publications. IEEE Signal
    Processing Magazine 23(1), 82--87.
    """

    # Triangular window function
    window = N.sqrt(3.0) / 8.0 * N.bartlett(num_colors)

    # Independent variable
    t = N.linspace(N.sqrt(3.0), 0.0, num_colors)

    # Initial values
    operand = (t - N.sqrt(3.0) / 2.0) * num_cycles * 2.0 * N.pi / N.sqrt(3.0)
    r0 = t
    g0 = window * N.cos(operand)
    b0 = window * N.sin(operand)

    # Convert RG to polar, rotate, and convert back
    r1, g1 = _rotate(r0, g0, N.arcsin(1.0 / N.sqrt(3.0)))
    b1 = b0

    # Convert RB to polar, rotate, and convert back
    r2, b2 = _rotate(r1, b1, N.pi / 4.0)
    g2 = g1

    # Ensure finite precision effects don't exceed unit cube boundaries
    r = r2.clip(0.0, 1.0)
    g = g2.clip(0.0, 1.0)
    b = b2.clip(0.0, 1.0)

    the_map = N.vstack((r, g, b)).T
    return ColorMapper.from_palette_array(the_map[::-1 if reverse else 1],
                                          range=rng,
                                          **traits)
示例#10
0
def isoluminant(rng, num_cycles=1, num_colors=256, reverse=False, **traits):
    """
    Generator function for a Chaco color scale that cycles through the hues
    @num_cycles times, while maintaining monotonic luminance (i.e., if it is
    printed in black and white, then it will be perceptually equal to a linear
    grayscale.

    Ported from the Matlab(R) code from: McNames, J. (2006). An effective color
    scale for simultaneous color and gray-scale publications. IEEE Signal
    Processing Magazine 23(1), 82--87.
    """

    # Triangular window function
    window = N.sqrt(3.0) / 8.0 * N.bartlett(num_colors)

    # Independent variable
    t = N.linspace(N.sqrt(3.0), 0.0, num_colors)

    # Initial values
    operand = (t - N.sqrt(3.0) / 2.0) * num_cycles * 2.0 * N.pi / N.sqrt(3.0)
    r0 = t
    g0 = window * N.cos(operand)
    b0 = window * N.sin(operand)

    # Convert RG to polar, rotate, and convert back
    r1, g1 = _rotate(r0, g0, N.arcsin(1.0 / N.sqrt(3.0)))
    b1 = b0

    # Convert RB to polar, rotate, and convert back
    r2, b2 = _rotate(r1, b1, N.pi / 4.0)
    g2 = g1

    # Ensure finite precision effects don't exceed unit cube boundaries
    r = r2.clip(0.0, 1.0)
    g = g2.clip(0.0, 1.0)
    b = b2.clip(0.0, 1.0)

    the_map = N.vstack((r, g, b)).T
    return ColorMapper.from_palette_array(the_map[::-1 if reverse else 1],
        range=rng, **traits)
示例#11
0
def awesome(rng, **traits):
    """
    Generator function for a Chaco color scale that has low-intensity contrast.
    """
    return ColorMapper.from_palette_array(N.loadtxt("../data/awesomecolormap.csv", delimiter=","), range=rng, **traits)
示例#12
0
 def change_colormap(self):
     self.conn_mat.color_mapper = ColorMapper.from_palette_array(
         self.ds.opts.connmat_map._pl(xrange(256)))
     self.conn_mat.request_redraw()
示例#13
0
文件: dataview.py 项目: aestrivex/cvu
 def change_colormap(self):
     self.conn_mat.color_mapper = ColorMapper.from_palette_array(
         self.ds.opts.connmat_map._pl(xrange(256)))
     self.conn_mat.request_redraw()