def quatplot3D(self, quatcomps, c, skipinds=range(4), azim=-60, elev=30, alphaall=.2, alphashell=1., fontsize=14, outline=True, **kwargs): numsubs=int(self.nint//4)+1 quatcomps=numpy.int32(numpy.round(quatcomps*self.nint)) for nshell in range(int(self.nint//4)+int(self.nint%4>0)): ba=((quatcomps==nshell).sum(axis=1, dtype='int32')>0)&((quatcomps>=nshell).prod(axis=1, dtype='int32')>0) shellcomps=quatcomps[ba] shellc=c[ba] q=QuaternaryPlot((1, numsubs, nshell+1), outline=outline) if alphaall>0: q.plot3D(quatcomps*1./self.nint,c, alpha=alphaall, **kwargs) if alphashell>0: q.plot3D(shellcomps*1./self.nint,shellc, alpha=alphashell, **kwargs) if fontsize>0: q.label(ha='center', va='center', fontsize=fontsize) q.set_projection(azim=azim, elev=elev) if self.nint%4==0: #single point with no frame ba=(quatcomps==self.nint//4).prod(axis=1, dtype='int32')>0 if True in ba: shellcomps=quatcomps[ba]#only 1 comp but might be duplicated shellc=c[ba] q=QuaternaryPlot((1, numsubs, numsubs), outline=outline) q.plot3D(quatcomps*1./self.nint,c, alpha=alphaall, **kwargs) q.plot3D(shellcomps*1./self.nint,shellc, alpha=alphashell, **kwargs) if fontsize>0: q.label(ha='center', va='center', fontsize=fontsize) q.set_projection(azim=azim, elev=elev)
def __init__(self, parent=None, title='', folderpath=None): super(dialog, self).__init__(parent) plotw = plotwidget(self) ax = plotw.axes intervs = 20 compsint = [[b, c, (intervs - a - b - c), a] for a in numpy.arange(0, intervs + 1)[::-1] for b in numpy.arange(0, intervs + 1 - a) for c in numpy.arange(0, intervs + 1 - a - b)][::-1] print len(compsint) comps = numpy.float32(compsint) / intervs pylab.figure() stpquat = QuaternaryPlot(111) cols = stpquat.rgb_comp(comps) stpquat.scatter(comps, c=cols, s=100, edgecolors='none') stpquat.label() self.tf = ternaryfaces_shells(ax, nintervals=intervs) self.tf.label() self.tf.scatter(comps, cols, skipinds=[0, 1, 2, 3], s='patch') QObject.connect(plotw, SIGNAL("genericclickonplot"), self.plotclick) mainlayout = QGridLayout() mainlayout.addWidget(plotw, 0, 0) self.setLayout(mainlayout)
def __init__(self, parent=None, title='', folderpath=None): super(dialog, self).__init__(parent) plotw=plotwidget(self) ax=plotw.axes intervs=20 compsint=[[b, c, (intervs-a-b-c), a] for a in numpy.arange(0,intervs+1)[::-1] for b in numpy.arange(0,intervs+1-a) for c in numpy.arange(0,intervs+1-a-b)][::-1] print len(compsint) comps=numpy.float32(compsint)/intervs pylab.figure() stpquat=QuaternaryPlot(111) cols=stpquat.rgb_comp(comps) stpquat.scatter(comps, c=cols, s=100, edgecolors='none') stpquat.label() self.tf=ternaryfaces(ax) self.tf.label() self.tf.scatter(comps, cols, skipinds=[0, 1, 2, 3], s='patch') QObject.connect(plotw, SIGNAL("genericclickonplot"), self.plotclick) mainlayout=QGridLayout() mainlayout.addWidget(plotw, 0, 0) self.setLayout(mainlayout)
def plotbinarylines_axandinset(ellabels=['A', 'B', 'C', 'D'], fig=None, mainax=[.3, .12, .6, .83], insetax=[0, .7, .2, .3], numcomppts=21, view_azim=-159, view_elev=30, **kwargs): if fig is None: fig = pylab.figure(figsize=(8, 5)) ax = fig.add_axes(mainax) ax2 = fig.add_axes(insetax, projection='3d') stpq = QuaternaryPlot(ax2, ellabels=ellabels) comppairs = [] a = numpy.linspace(0, 1, 21) count = -1 for i in range(4): for j in range(i + 1, 4): count += 1 b = numpy.zeros((numcomppts, 4), dtype='float64') b[:, i] = a b[:, j] = 1. - a comppairs += [(c1, c2) for c1, c2 in zip(b[:-1], b[1:])] for (c1, c2) in comppairs: stpq.line(c1, c2, fmt='-', c=stpq.rgb_comp([(c1 + c2) / 2.])[0], **kwargs) stpq.set_projection(azim=view_azim, elev=view_elev) stpq.label() return ax, ax2
class binarylines: def __init__(self, ax, insetax, ellabels=['A', 'B', 'C', 'D'], offset=0.02, numcomppts=21, view_azim=-159, view_elev=30, **kwargs): self.ax=ax self.insetax=insetax self.ellabels=ellabels self.stpq=QuaternaryPlot(insetax, ellabels=ellabels, offset=offset) comppairs=[] a=numpy.linspace(0, 1, 21) count=-1 for i in range(4): for j in range(i+1, 4): count+=1 b=numpy.zeros((numcomppts, 4), dtype='float64') b[:, i]=a b[:, j]=1.-a comppairs+=[(c1, c2) for c1, c2 in zip(b[:-1], b[1:])] for (c1, c2) in comppairs: self.stpq.line(c1, c2, fmt='-', c=self.stpq.rgb_comp([(c1+c2)/2.])[0], **kwargs) self.stpq.set_projection(azim=view_azim, elev=view_elev) self.stpq.label() def plotbinaryfom(self, comps, fom, **kwargs): cb=comps>.001 ms=['<','>','^','v','s','D'] count=-1 for i in range(4): for j in range(i+1, 4): count+=1 k, l=tuple(set(range(4))-set([i, j])) barr=numpy.array([numpy.logical_not(b[k]|b[l]) for b in cb]) #numpy.logical_xor(b[i], b[j])& if not numpy.any(barr): continue cmps=comps[barr] inds=numpy.argsort(cmps[:, j]) cmps=cmps[inds] cols=self.stpq.rgb_comp(cmps) ys=fom[barr][inds] for count2, (c, col, y) in enumerate(zip(cmps, cols, ys)): if count2==len(ys)//2: self.ax.plot(c[j], y, marker=ms[count], c=col, markeredgecolor=col, label='%s,%s' %(self.ellabels[i], self.ellabels[j]), **kwargs) else: self.ax.plot(c[j], y, marker=ms[count], c=col, markeredgecolor=col, **kwargs) #self.ax.plot(c[j], y, marker=ms[count], c=col, markeredgecolor='None') for count3, (c1, col1, y1, c2, col2, y2) in enumerate(zip(cmps[:-1], cols[:-1], ys[:-1], cmps[1:], cols[1:], ys[1:])): col=numpy.array([col1, col2]).mean(axis=0) self.ax.plot([c1[j], c2[j]], [y1, y2], '-', c=col, **kwargs) def binarylineslegend(self, **kwargs): try: self.ax.legend(**kwargs) except: pass
def __init__(self, comps, parent=None, title='', folderpath=None): super(dialog, self).__init__(parent) plotw=plotwidget(self) ax=plotw.axes inds=np.where(comps[:, -1]==0.)[0] comps=comps[inds, :-1] #print comps.shape stpquat=QuaternaryPlot(ax) ax.cla() cols=stpquat.rgb_comp(comps) #stpquat.scatter(comps, c=cols, s=100, edgecolors='none') #stpquat.label() self.tf=ternaryfaces_shells(ax, nintervals=intervs) self.tf.label() self.tf.scatter(comps, cols, skipinds=[0, 1, 2, 3], s='patch') #only select comps plotw2=plotwidget(self, projection3d=True) ax=plotw2.axes #unary stpquat=QuaternaryPlot(ax) stpquat.scatter(comps, c=cols, s=100, edgecolors='none') stpquat.label() QObject.connect(plotw, SIGNAL("genericclickonplot"), self.plotclick) QObject.connect(plotw2, SIGNAL("genericclickonplot"), self.plotclick) mainlayout=QGridLayout() mainlayout.addWidget(plotw, 0, 0) mainlayout.addWidget(plotw2, 1, 0) self.setLayout(mainlayout)
def plotbinarylines_axandinset(ellabels=['A', 'B', 'C', 'D'], fig=None, mainax=[.3, .12, .6, .83], insetax=[0, .7, .2, .3], numcomppts=21, view_azim=-159, view_elev=30, **kwargs): if fig is None: fig=pylab.figure(figsize=(8, 5)) ax=fig.add_axes(mainax) ax2=fig.add_axes(insetax, projection='3d') stpq=QuaternaryPlot(ax2, ellabels=ellabels) comppairs=[] a=numpy.linspace(0, 1, 21) count=-1 for i in range(4): for j in range(i+1, 4): count+=1 b=numpy.zeros((numcomppts, 4), dtype='float64') b[:, i]=a b[:, j]=1.-a comppairs+=[(c1, c2) for c1, c2 in zip(b[:-1], b[1:])] for (c1, c2) in comppairs: stpq.line(c1, c2, fmt='-', c=stpq.rgb_comp([(c1+c2)/2.])[0], **kwargs) stpq.set_projection(azim=view_azim, elev=view_elev) stpq.label() return ax, ax2
def __init__(self, comps, parent=None, title='', folderpath=None): super(dialog, self).__init__(parent) plotw = plotwidget(self) ax = plotw.axes inds = np.where(comps[:, -1] == 0.)[0] comps = comps[inds, :-1] #print comps.shape stpquat = QuaternaryPlot(ax) ax.cla() cols = stpquat.rgb_comp(comps) #stpquat.scatter(comps, c=cols, s=100, edgecolors='none') #stpquat.label() self.tf = ternaryfaces_shells(ax, nintervals=intervs) self.tf.label() self.tf.scatter(comps, cols, skipinds=[0, 1, 2, 3], s='patch') #only select comps plotw2 = plotwidget(self, projection3d=True) ax = plotw2.axes #unary stpquat = QuaternaryPlot(ax) stpquat.scatter(comps, c=cols, s=100, edgecolors='none') stpquat.label() QObject.connect(plotw, SIGNAL("genericclickonplot"), self.plotclick) QObject.connect(plotw2, SIGNAL("genericclickonplot"), self.plotclick) mainlayout = QGridLayout() mainlayout.addWidget(plotw, 0, 0) mainlayout.addWidget(plotw2, 1, 0) self.setLayout(mainlayout)
stpq=QuaternaryPlot(111, ellabels=ellabels) comps=numpy.array([dropd[elkey] for elkey in elkeys]).T selectinds, distfromlin, lineparameter=stpq.filterbydistancefromline(comps, compverts[0], compverts[1], critdist, betweenpoints=betweenbool, invlogic=invertbool, returnall=True) dropd['lineparameter']=lineparameter dropd['distfromlin']=distfromlin lineparameter=lineparameter[selectinds] cols=stpq.rgb_comp(comps[selectinds]) stpq.plotbycolor(comps[selectinds], cols, marker='o', markersize=5, alpha=.6) stpq.line(compverts[0], compverts[1], lw=2) #stpq.scatter(comps[selectinds], pointsize stpq.set_projection(azim=view_azim, elev=view_elev) stpq.label(fontsize=20) pylab.savefig(os.path.join(savefolder, 'QuatPoints.png')) pylab.figure() for k, v in dropd.iteritems(): # if k in elkeys or k in ellabels or k in ['Sample', 'x(mm)', 'y(mm)', 'compositions']: # continue pylab.clf() ax=pylab.subplot(111) fomselect=v[selectinds] stpq.plotfomalonglineparameter(ax, lineparameter, fomselect, compend1=compverts[0], compend2=compverts[1], lineparticks=numpy.linspace(0, 1, 5), ls='none', marker='.', ticklabelkwargdict=dict([('rotation', -20), ('horizontalalignment', 'left')])) pylab.ylabel(k) pylab.subplots_adjust(bottom=.15, left=.15, right=.8) pylab.savefig(os.path.join(savefolder, k+'.png'))
if examplenum == 0: compvert2 = numpy.array([0.125, 0.125, 0.6, 0.15]) compvert0 = numpy.array([0.2, 0.2, 0.0, 0.6]) compvert1 = numpy.array([1.0, 0.0, 0.0, 0]) critdist = 0.04 withintriangle = False elif examplenum == 1: compvert2 = numpy.array([0.125, 0.125, 0.6, 0.15]) compvert0 = numpy.array([0.2, 0.2, 0.0, 0.6]) compvert1 = numpy.array([1.0, 0.0, 0.0, 0]) critdist = 0.04 withintriangle = True q.scatter(comps, c=comps[:, 3]) q.label(ha="center", va="center", fontsize=16) q.set_projection(azim=-17, elev=-6) inds, distfromplane, xyparr, xyp_verts, intriangle = q2.filterbydistancefromplane( comps, compvert0, compvert1, compvert2, critdist, withintriangle=withintriangle, invlogic=False, returnall=True ) indsnot = q2.filterbydistancefromplane( comps, compvert0, compvert1, compvert2, critdist, withintriangle=withintriangle, invlogic=True ) print len(inds), " points" q2.scatter(comps[inds], c=comps[inds, 3]) q2.scatter(comps[indsnot], c="grey", marker=".", s=5) q2.line(compvert0, compvert1) q2.line(compvert1, compvert2) q2.line(compvert2, compvert0)
from myquaternaryutility import QuaternaryPlot from quaternary_FOM_stackedtern10 import * ellabels=['Aa', 'Bb', 'Cc', 'Dd'] axl, stpl=make10ternaxes(ellabels=ellabels) gridi=30 comps_10full=[(a*1./gridi, b*1./gridi, c*1./gridi, (gridi-a-b-c)*1./gridi) for a in numpy.arange(0,1+gridi) for b in numpy.arange(0,1+gridi-a) for c in numpy.arange(0,1+gridi-a-b)] comps_10full=list(set(comps_10full)) print len(comps_10full) #plotpoints_cmyk comps_10full=numpy.array(comps_10full) pylab.figure() stpquat=QuaternaryPlot(111, ellabels=ellabels) cols=stpquat.rgb_comp(comps_10full) stpquat.scatter(comps_10full, c=cols, s=20, edgecolors='none') norm=colors.Normalize(vmin=0, vmax=1) cmap=cm.jet scatter_10axes(comps_10full, cols, stpl, s=20, edgecolors='none', cb=True, norm=norm, cmap=cmap) stpquat.label() pylab.savefig('stackedtern_quat.png') pylab.figure(axl[0].figure.number) pylab.savefig('stackedtern.png') pylab.show()
ax2.set_aspect(1) mapbl=ax2.scatter(x, y, c=fom, s=60, marker='s', edgecolors='none', cmap=cmap, norm=norm) ax2.set_xlim(x.min()-2, x.max()+2) ax2.set_ylim(y.min()-2, y.max()+2) ax2.set_title('plate %d' %(count+1)) #pylab.title('CP1Ess (V) Map') comp=numpy.array([[dropd['A'][i], dropd['B'][i], dropd['C'][i], dropd['D'][i]] for i in dropinds]) comp=numpy.array([a/a.sum() for a in comp]) figquat=pylab.figure(figsize=(8, 8)) stp = QuaternaryPlot(111, minlist=[0., 0., 0., 0.], ellabels=ellabels) stp.scatter(comp, c=fom, s=pointsize, edgecolors='none', cmap=cmap, norm=norm) stp.label(ha='center', va='center', fontsize=16) stp.set_projection(azim=view_azim, elev=view_elev) caxquat=figquat.add_axes((.83, .3, .04, .4)) cb=pylab.colorbar(stp.mappable, cax=caxquat, extend=extend) cb.set_label(fomlabel, fontsize=16) stp.ax.set_title('plate %d' %(count+1)) compsall+=list(comp) fomall+=list(fom) figquatall+=[figquat] plateindall+=[count]*len(fom) fig.subplots_adjust(left=.05, bottom=.03, top=.96, right=.83, hspace=.14) cax=fig.add_axes((.85, .3, .04, .4)) cb=pylab.colorbar(mapbl, cax=cax, extend=extend) cb.set_label(fomlabel, fontsize=20)
##f.close() # sys.path.append('C:/Users/Gregoire/Documents/PythonCode/ternaryplot') from myquaternaryutility import QuaternaryPlot from quaternary_FOM_stackedtern20 import * axl, stpl=make20ternaxes() # #for d in dlist: # c=numpy.array([d[el] for el in ['A', 'B', 'C', 'D']]) # if c.sum()>0: # c/=c.sum() # d['compositions']=c #carr=numpy.array([d['compositions'] for d in dlist]) carr=numpy.array(comps) pylab.figure() stpq=QuaternaryPlot(111) #stpq.scatter(carr) cols=stpq.rgb_comp(carr) stpq.scatter(carr, c=cols, s=20, edgecolors='none') scatter_20axes(carr, cols, stpl, s=20, edgecolors='none', cb=False) stpq.label() #axl[0].figure.savefig('C:/Users/Gregoire/Documents/CaltechWork/platemaps/nestedtetr/test2.png') pylab.show()
for countends, (p1, p2) in enumerate(itertools.combinations(xyz_endmembers, 2)): for countlines, (l0, l1) in enumerate(xyz_lineendpairs): t = numpy.cross(p1 - p0, p2 - p0) #this is where the line intersects the plane, although it may not be within the triangle xyz_intr = l0 + (numpy.dot(t, p0 - l0) / numpy.dot(t, l1 - l0)) * (l1 - l0) #check within triangle phase field boundary and if so draw a green dot at itnersection and a translucent triangle xyz_triverts = numpy.array([p0, p1, p2]) if intriangle(xyz_intr, xyz_triverts): xyz_intr_dlist += [ dict({}, xyz_intr=xyz_intr, xyz_triverts=xyz_triverts, xyz_lineends=(l0, l1), index_endmems=countends, index_lineends=countlines) ] q.scatter(q.toComp([xyz_intr]), c='g', s=20) verts = [[p0, p1, p2]] collection = Poly3DCollection(verts, linewidths=0, alpha=0.2) face_color = [0.5, 0.5, 0.5] collection.set_facecolor(face_color) q.ax.add_collection3d(collection) q.label(ha='center', va='center', fontsize=16) q.set_projection(azim=-17, elev=-6) pylab.show()
from myquaternaryutility import QuaternaryPlot gridi = 20 comps_10full = [(a * 1. / gridi, b * 1. / gridi, c * 1. / gridi, (gridi - a - b - c) * 1. / gridi) for a in numpy.arange(0, 1 + gridi) for b in numpy.arange(0, 1 + gridi - a) for c in numpy.arange(0, 1 + gridi - a - b)] comps_10full = list(set(comps_10full)) print len(comps_10full) #comps_10full=[[1., 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] comps_10full = numpy.array(comps_10full) pylab.figure() stpquat = QuaternaryPlot(111) cols = stpquat.rgb_comp(comps_10full) stpquat.scatter(comps_10full, c=cols, s=20, edgecolors='none') stpquat.label() pylab.figure() ax = pylab.gca() tf = ternaryfaces(ax, nintervals=gridi) tf.label() #inds_x_y=tf.toCart(comps_10full) tf.scatter(comps_10full, cols, skipinds=[0, 1, 2, 3], s='patch') pylab.show()
ax2=fig.add_subplot(len(dropdl), 1, count+1) ax2.set_aspect(1) mapbl=ax2.scatter(x, y, c=fom, s=60, marker='s', edgecolors='none', cmap=cmap, norm=norm) ax2.set_xlim(x.min()-2, x.max()+2) ax2.set_ylim(y.min()-2, y.max()+2) ax2.set_title('plate %d' %(count+1)) #pylab.title('CP1Ess (V) Map') figquat=pylab.figure(figsize=(8, 8)) stp = QuaternaryPlot(111, minlist=[0., 0., 0., 0.], ellabels=ellabels) stp.scatter(comp, c=fom, s=pointsize, edgecolors='none', cmap=cmap, norm=norm) stp.label(ha='center', va='center', fontsize=20) stp.set_projection(azim=view_azim, elev=view_elev) caxquat=figquat.add_axes((.83, .3, .04, .4)) cb=pylab.colorbar(stp.mappable, cax=caxquat, extend=extend) cb.set_label(fomlabel, fontsize=16) stp.ax.set_title('plate %d' %(count+1)) figquatall+=[figquat] compsall=numpy.array(compsall) fomall=numpy.array(fomall) plateindall=numpy.array(plateindall) codeall=numpy.array(codeall) code0inds=numpy.where(codeall==0) code02inds=numpy.where(codeall!=1) code2inds=numpy.where(codeall==2)
# sys.path.append('C:/Users/Gregoire/Documents/PythonCode/ternaryplot') from myquaternaryutility import QuaternaryPlot from quaternary_FOM_stackedtern20 import * axl, stpl = make20ternaxes() # #for d in dlist: # c=numpy.array([d[el] for el in ['A', 'B', 'C', 'D']]) # if c.sum()>0: # c/=c.sum() # d['compositions']=c #carr=numpy.array([d['compositions'] for d in dlist]) carr = numpy.array(comps) pylab.figure() stpq = QuaternaryPlot(111) #stpq.scatter(carr) cols = stpq.rgb_comp(carr) stpq.scatter(carr, c=cols, s=20, edgecolors='none') scatter_20axes(carr, cols, stpl, s=20, edgecolors='none', cb=False) stpq.label() axl[0].figure.savefig( 'C:/Users/Gregoire/Documents/CaltechWork/platemaps/nestedtetr/test2.png') pylab.show()
selectinds, distfromplane, xyparr, xyp_verts,intriangle=stpqp.filterbydistancefromplane(comps, compvertsp[0], compvertsp[1], compvertsp[2], critdistp, withintriangle=betweenbool, invlogic=invertbool, returnall=True) xyparr=xyparr[selectinds] cols=stpqp.rgb_comp(comps[selectinds]) stpqp.plotbycolor(comps[selectinds], cols, marker='o', markersize=3, alpha=1) stpqp.line(compvertsp[0], compvertsp[1], lw=2) stpqp.line(compvertsp[2], compvertsp[1], lw=2) stpqp.line(compvertsp[0], compvertsp[2], lw=2) #stpqp.scatter(comps[selectinds], pointsize stpqp.set_projection(azim=view_azim, elev=view_elev) stpqp.label(fontsize=20) pylab.savefig(os.path.join(savefolder, 'QuatPointsPlane.png')) pylab.savefig(os.path.join(savefolder, 'QuatPointsPlane.eps')) pylab.figure() #axq=pylab.subplot(111) stpql=QuaternaryPlot(111, ellabels=ellabels) selectinds, distfromlin, lineparameter=stpql.filterbydistancefromline(comps, compverts[0], compverts[1], critdist, betweenpoints=betweenbool, invlogic=invertbool, returnall=True) dropd['lineparameter']=lineparameter dropd['distfromlin']=distfromlin lineparameter=lineparameter[selectinds]
import pylab, numpy from myquaternaryutility import QuaternaryPlot q=QuaternaryPlot(111) #t=numpy.linspace(0,1.,5) #comps=[[a,b,c,d] for a in t for b in t for c in t for d in t if a+b+c+d==1.] #comps=numpy.float32(comps) t=numpy.linspace(0,1.,30) comps=[[a,b,1.-a-b-(2.*a**2+b),2.*a**2+b] for a in t for b in t[:10] if a+b+(2.*a**2+b)<=1.] comps=numpy.float32(comps) x, y, z=q.toCart(comps) q.scatter(comps,c=comps[:,3]) #q.ax.scatter(x, y, z, c=z) q.plotabcprojection(comps, c=(.4, .4, .4)) q.label(ha='center', va='center', fontsize=16) q.set_projection(azim=-17, elev=-6) pylab.show()
def plot(self): s = 25 self.plotw_tern.axes.cla() self.plotw_quat.axes.cla() self.cbax_quat.cla() self.cbax_tern.cla() fom = self.fom azim = -159.0 elev = 30.0 vstr = str(self.azimelevLineEdit.text()).strip() if "," in vstr: a, b, c = vstr.partition(",") try: a = myeval(a.strip()) c = myeval(c.strip()) self.vmin = a self.vmax = c except: pass if self.revcmapCheckBox.isChecked(): cmap = cm.jet_r else: cmap = cm.jet clip = True skipoutofrange = [False, False] self.vmin = fom.min() self.vmax = fom.max() vstr = str(self.vminmaxLineEdit.text()).strip() if "," in vstr: a, b, c = vstr.partition(",") try: a = myeval(a.strip()) c = myeval(c.strip()) self.vmin = a self.vmax = c for count, (fcn, le) in enumerate( zip([cmap.set_under, cmap.set_over], [self.belowrangecolLineEdit, self.aboverangecolLineEdit]) ): vstr = str(le.text()).strip() vstr = vstr.replace('"', "").replace("'", "") print "^^^", vstr, "none" in vstr or "None" in vstr if "none" in vstr or "None" in vstr: skipoutofrange[count] = True continue if len(vstr) == 0: continue c = col_string(vstr) try: fcn(c) clip = False except: print "color entry not understood:", vstr except: pass print "4" norm = colors.Normalize(vmin=self.vmin, vmax=self.vmax, clip=clip) print "fom min, max, mean, std:", fom.min(), fom.max(), fom.mean(), fom.std() comps = self.comps # comment out this skipoutofrange becuase it could mess up the indexing # print 'skipoutofrange', skipoutofrange # print len(fom) # if skipoutofrange[0]: # inds=numpy.where(fom>=self.vmin) # fom=fom[inds] # comps=comps[inds] # print len(fom) # if skipoutofrange[1]: # inds=numpy.where(fom<=self.vmax) # fom=fom[inds] # comps=comps[inds] # print len(fom) if numpy.any(fom > self.vmax): if numpy.any(fom < self.vmin): extend = "both" else: extend = "max" elif numpy.any(fom < self.vmin): extend = "min" else: extend = "neither" print "extend ", extend i = self.ternskipComboBox.currentIndex() inds = [j for j in range(4) if j != i][:3] terncomps = numpy.array([c[inds] / c[inds].sum() for c in comps]) reordercomps = comps[:, inds + [i]] reorderlabels = [self.ellabels[j] for j in inds + [i]] fomselect = fom[self.selectinds] compsselect = comps[self.selectinds] reordercompsselect = reordercomps[self.selectinds] fomlabel = self.dataclass.fomlabel self.stackedternplotdict = dict( [ ("comps", reordercomps), ("fom", fom), ("cmap", cmap), ("norm", norm), ("ellabels", reorderlabels), ("fomlabel", fomlabel), ("extend", extend), ] ) self.echem30_all.clearandplot(self.stackedternplotdict, cb=True, ellabels=reorderlabels) print len(fomselect), " samples selected" if len(fomselect) > 0: self.stackedternplotdictselect = dict( [ ("comps", reordercompsselect), ("fom", fomselect), ("cmap", cmap), ("norm", norm), ("ellabels", reorderlabels), ("fomlabel", fomlabel), ("extend", extend), ] ) self.echem30_select.clearandplot(self.stackedternplotdictselect, cb=True, ellabels=reorderlabels) quat = QuaternaryPlot(self.plotw_quat.axes, ellabels=self.ellabels, offset=0) quat.label() quat.scatter( compsselect, c=fomselect, s=s, cmap=cmap, norm=norm, edgecolor="none" ) # vmin=self.vmin, vmax=self.vmax, cb = self.plotw_quat.fig.colorbar( quat.mappable, cax=self.cbax_quat, extend=extend, format=autocolorbarformat((fom.min(), fom.max())) ) cb.set_label(fomlabel, fontsize=18) quat.set_projection(azim=azim, elev=elev) if self.calctype == 0: quat.line(self.compverts[0], self.compverts[1]) self.quatcalc.plotfomalonglineparameter( self.plotw_tern.axes, self.lineparameter, fomselect, compend1=self.compverts[0], compend2=self.compverts[1], lineparticks=numpy.linspace(0, 1, 4), ls="none", marker=".", ) elif self.calctype == 1: self.quatcalc.plotfominselectedplane( self.plotw_tern.axes, self.xyparr, fomselect, xyp_verts=self.xyp_verts, vertcomps_labels=[self.compverts[0], self.compverts[1], self.compverts[2]], s=20, edgecolor="none", cmap=cmap, norm=norm, ) quat.line(self.compverts[0], self.compverts[1]) quat.line(self.compverts[0], self.compverts[2]) quat.line(self.compverts[2], self.compverts[1]) cb = self.plotw_tern.fig.colorbar( quat.mappable, cax=self.cbax_tern, extend=extend, format=autocolorbarformat((fom.min(), fom.max())) ) cb.set_label(fomlabel, fontsize=18) self.plotw_quat.axes.mouse_init() self.plotw_quat.axes.set_axis_off() self.plotw_tern.fig.canvas.draw() self.plotw_quat.fig.canvas.draw()