q=TernaryPlot(111)


#define these to be modified for each end member
z=numpy.zeros(3, dtype='float64')
ctr2=numpy.ones(3, dtype='float64')/2.
endmembers=[]
lineendpairs=[]
#iterate over 4 end members and draw a line from there to center of opposing face, e.g. (0,.33,.33,.33)
for i in range(3):
    a=copy.copy(z)
    a[i]=1.
    b=copy.copy(ctr2)
    b[i]=0.
    q.line(a, b, fmt='b-')
    q.scatter([b], c='b', s=15)
    endmembers+=[a]
    lineendpairs+=[[a, b]]
#convert the end members and pairs of endpts to cartesian
xy_lineendpairs=[numpy.array(q.toCart(ls)).T for ls in lineendpairs]
xy_endmembers=numpy.array(q.toCart(endmembers)).T

#choose the composition of a phase and draw the trivial phase field lines
phcomp=numpy.array([.5, .3, .2])
q.scatter([phcomp], c='r', s=20)
for i in range(3):
    a=copy.copy(z)
    a[i]=1.
    q.line(a, phcomp, fmt='r-')

# iterate over all 4 phase field triangular boundaries (triangle defined by 3 points, the phase p0 and 2 end members p1,p2) and all 4 composition lines. find intersections
ca=numpy.array(map(operator.itemgetter(5), data))
title=r'Film thickness (nm)'

#********start ternary plotting
pylab.figure(figsize=(10, 6))
ax=pylab.subplot(111)
##stp = TernaryPlot(ax, ellabels=['Au', 'Si', 'Cu']) 
stp = TernaryPlot(ax, ellabels=['Au', 'Si', 'Cu'], minlist=[0.47, 0.12, .2])
stp.grid(nintervals=3)
stp.label(fontsize=14)




#plot za value from above by color
stp.scatter(ca, s=80, c=za, label='_', cmap=cm.jet, alpha=1., marker='o') #scatter doesn't work well with legend, so label="_" (hides it); cmap chooses the color scheme; alpha allows some transparency to see overlapping data
stp.colorbar(title, fontsize=14)
#stp.ax.set_title(title, fontsize=14)
#****

##plot cellnumbers
#celllist=[1, 2]+range(4, 21)+[22]+[24, 25]
#for selectcell in celllist:
#    stp.text(comp[selectcell-1], `selectcell`, ha='center', va='center', color='r', fontsize=12)

##plot points by color
#celllist=[1, 2]+range(4, 21)+[22]+[24, 25]
#minlist=[c.min() for c in comp[numpy.array(celllist)-1, :].T]
#rangelist=numpy.float32([[m, 1.-numpy.concatenate([minlist[:i], minlist[i+1:]]).sum()] for i, m in enumerate(minlist)])
#colors=stp.color_comp_calc(comp[numpy.array(celllist)-1, :], rangelist=rangelist)
#stp.colorcompplot(comp[numpy.array(celllist)-1, :], '.', colors=colors, markersize=20)
Ejemplo n.º 3
0
q = TernaryPlot(111)

#define these to be modified for each end member
z = numpy.zeros(3, dtype='float64')
ctr2 = numpy.ones(3, dtype='float64') / 2.
endmembers = []
lineendpairs = []
#iterate over 4 end members and draw a line from there to center of opposing face, e.g. (0,.33,.33,.33)
for i in range(3):
    a = copy.copy(z)
    a[i] = 1.
    b = copy.copy(ctr2)
    b[i] = 0.
    q.line(a, b, fmt='b-')
    q.scatter([b], c='b', s=15)
    endmembers += [a]
    lineendpairs += [[a, b]]
#convert the end members and pairs of endpts to cartesian
xy_lineendpairs = [numpy.array(q.toCart(ls)).T for ls in lineendpairs]
xy_endmembers = numpy.array(q.toCart(endmembers)).T

#choose the composition of a phase and draw the trivial phase field lines
phcomp = numpy.array([.5, .3, .2])
q.scatter([phcomp], c='r', s=20)
for i in range(3):
    a = copy.copy(z)
    a[i] = 1.
    q.line(a, phcomp, fmt='r-')

# iterate over all 4 phase field triangular boundaries (triangle defined by 3 points, the phase p0 and 2 end members p1,p2) and all 4 composition lines. find intersections