def makeCmap(name,rgbVals,blackened=True):
    cnames = 'red','green','blue'
    l = len(rgbVals[0])-1
    cpos = [ 1.0*i/l for i in range(l+1) ]
    vblack = [ [0.]+v[1:] for v in rgbVals ]
    vals1,vals2 = (vblack if blackened else rgbVals), rgbVals
    d = { c:totuple(zip(cpos,v1,v2))
         for c,v1,v2 in zip(cnames,vals1,vals2) }
    return mpl.colors.LinearSegmentedColormap(name,d)
Пример #2
0
def GetXYListAndPolyListFromCVLS(cVLS,allValsByFrame,orderOfSCsByValueByFrame):
    '''Turn a cVLS into a list of points (xyList) and a dictionary of index lists (into xyList) with cellID keys (polyList)
       polyList basically contains the information that reconstructs each individual contour from points
       Appends the first point to the end of each list to close the loop and makes plotting cleaner, but be cautious of this'''
    numFrames = len(cVLS)
    xyList = [ sorted(list(set(  tuple(pt) for c in cvlsByVal for pt in c[2]  ))) for cvlsByVal in cVLS ]
    polyList = []
    
    for t in range(numFrames):
        polyList.append({})
        for v in allValsByFrame[t]:
            subContours = [ ( cVLS[t][-index][2][::-1] if index<0 else cVLS[t][index][2] )
                           for index in orderOfSCsByValueByFrame[t][v] ] # reconstruct the sc's, flipping if index is negative
            polyList[-1][v] = [ xyList[t].index(totuple(pt)) for sc in subContours for pt in sc[:-1] ]
            polyList[-1][v] = polyList[-1][v]+[polyList[-1][v][0]] # Tack on the first point at the end to close the loop
                                                                   # VFMin doesn't like this format; make sure to remove this last point before saving to a file or passing to VFM...
            #polyList[-1][v] = removeDuplicates(polyList[-1][v])+[polyList[-1][v][0]] # Remove interior duplication...
    return xyList,polyList