Python matplotlib.cm.Blues() Examples

The following are 1 code examples for showing how to use matplotlib.cm.Blues(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module matplotlib.cm , or try the search function .

Example 1
Project: pynoddy   Author: cgre-aachen   File: hive_plot.py    License: GNU General Public License v2.0 4 votes vote down vote up
def build_edge_colormaps(self):
        '''
        Builds a colormap for each group of edges passed.
        
        The self.edge_colormap dict should have the following structure:
        
         { 'group_name' : {e1 : 'r', e2 : 0.4, e3: 0.2, cm=cm.Blues}, 'grp2' : 
         {e4 : 0.2, e5: 30, e6: 10, 'cm' : 'alpha', color' : 'r'}}
        '''
        import matplotlib.colors as cols
        
        if self.edge_colormap is None:
            self.edge_colormap = {}
            
        for group, edge_list in self.edges.iteritems():
            if not self.edge_colormap.has_key(group):
                self.edge_colormap[group] = {} #init group
              
            #get colormap
            c_map = self.edge_colormap[group].get('cm',cm.Blues)
            
            #calculate  value range
            try:
                minv = float(min ( [ v for v in self.edge_colormap[group].values()  if isinstance(v, numbers.Number)] ))
                maxv = float(max ( [ v for v in self.edge_colormap[group].values() if isinstance(v, numbers.Number)] ))
            except ValueError: #empty sequence
                minv=0
                maxv=0
            for e in edge_list: #loop through edges in this group
                v = self.edge_colormap[group].get(e, 'b') #get color. default is blue.
                
                if isinstance(v, numbers.Number): #if value is a number (we need to use colour ramp)
                    if c_map == 'alpha': #map values to alpha
                        if not maxv == minv:
                            alpha = (v - minv) / (maxv - minv)
                            color = self.edge_colormap[group].get('color','b')
                        else:
                            alpha = 0.6
                            color = self.edge_colormap[group].get('color','b')
                        rgb = cols.colorConverter.to_rgb(color)
                        self.edge_colormap[group][e] = rgb + (alpha,)
                    else: #use defined colormap
                        self.edge_colormap[group][e] = c_map( (v - minv) / (maxv - minv) )
                else:
                    #set default alpha to 0.6
                    rgb = cols.colorConverter.to_rgb(v)
                    self.edge_colormap[group][e] = rgb + (0.6,)