value = cursor.fetchall()
 value = value[0][0]
 
 try:
     value_channel_dict[channel].append(value)
 except KeyError:
     value_channel_dict[channel] = []
     value_channel_dict[channel].append(value)
     
 # determine corresponding isotype
 if channel == channel1[0]:
     isotype = igdbq.get_H_isotype(int(event[0]), cursor)
     if isotype:
         isotype = isotype[0][0]
         try:
             color = igdbplt.get_color(isotype)
             # some are IGKC???
         except KeyError:
                 color = 'black'
     else: color = 'white'
         
     try:
         value_channel_dict['color'].append(color)
     except KeyError:
         value_channel_dict['color'] = []
         value_channel_dict['color'].append(color)
     
     factor = 1
     if args.mutation == True:
         factor = igdbq.get_mutation_count(int(event[0]), cursor)
         try:
        if args.normalize == True:
            norm_fact = 1./sum(gene_heights)
            plt.xlim(0,1)
            norm = "norm"
        else:
            norm_fact = 1
            norm = "abs"
        palette = igplt.random_colors(200)
        bottom = 0
        for height, label in zip(gene_heights, gene_labels):
            # make redundant labels dissapear from legend
            if label not in label_list:
                label_list.append(label)
                leg_label = label
            else: leg_label = ""
            plt.bar(left = bottom, height = 0.8, width = height*norm_fact, orientation='horizontal', label = leg_label, bottom = i, color = igplt.get_color(label) + (0.8,))
            
            bottom = height*norm_fact + bottom
           
        
        # format legend
        if len(label_list) > 15:
            ncol = 2
        else: ncol = 1
    lgd = plt.legend(loc='center left', bbox_to_anchor=(1, 0.5), ncol = ncol)
    plt.yticks(np.arange(len(event_names))+0.4, event_names)
    lbl = plt.xlabel('Counts')
    plt.ylim(-0.1, len(event_names)-0.1)
    ttl = plt.title(igplt.plot_log('Segment usage', sys.argv, db))
    plt.savefig(args.outputdir + "/%s_%s_%s_%s_%s_%s_%s" % (db, args.event_infile, resolve, segment, args.locus, args.plotstyle, norm) + '.pdf', bbox_extra_artists=(ttl,lbl,), bbox_inches='tight')
else: