Пример #1
0
    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 __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 __init__(self, parent, comp, cols, cbaxrect=[.88, .2, .04, .6], ellabels=['A', 'B', 'C', 'D'], **kwargs):
     super(ternaryfacesWidget, self).__init__(parent)
     
     mainlayout=QVBoxLayout()
     
     self.plotw=plotwidget(self, width=8, height=4)
     self.plotw.fig.clf()
     self.ax=self.plotw.fig.add_axes([.05, .05, .78, .9])#add_subplot(111)
     if not cbaxrect is None:
         self.cbax=self.plotw.fig.add_axes(cbaxrect)
     
     self.tf=ternaryfaces(self.ax, ellabels=ellabels, offset=.04)
     self.tf.label(fontsize=16)
     
     mainlayout.addWidget(self.plotw)
     
     self.buttonBox = QDialogButtonBox(self)
     self.buttonBox.setGeometry(QRect(520, 195, 160, 26))
     self.buttonBox.setOrientation(Qt.Horizontal)
     self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)
     QObject.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
     mainlayout.addWidget(self.buttonBox)
     
     self.setLayout(mainlayout)
     
     self.tf.scatter(comp, cols, s=20, edgecolors='none', **kwargs)
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()

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()