コード例 #1
0
ファイル: imagesc.py プロジェクト: guaka/py-audio-analysis
def plot2d(arr, size=(700, 600), palette=gray, dontscale=False):

    if dontscale:
        im = pilutil.toimage(MLab.flipud(arr), pal=palette, cmin=0., cmax=1.)
    else:
        im = pilutil.toimage(MLab.flipud(arr), pal=palette)

    if size:
        im = im.resize(size)

    im.show()
コード例 #2
0
ファイル: qtest2.py プロジェクト: guaka/py-audio-analysis
 def setPalette(self, palette):
     self.palette = palette
     if self.array:
         self.image = pilutil.toimage(MLab.flipud(self.array), pal=palette)
         self.doPlotImage()
     if self.legend:
         self.legend.setImagePlot(self)
コード例 #3
0
ファイル: qtest2.py プロジェクト: guaka/py-audio-analysis
    def setArray(self, arr, palette=palettes["brownish"]):
        self.array = arr

        # if no_scaling: #for subplots and stuff like that...
        #  im = pilutil.toimage(MLab.flipud(arr), pal = palette, cmin = 0., cmax = 1.)
        self.image = pilutil.toimage(MLab.flipud(arr), pal=palette)
        self.afterResize()
コード例 #4
0
ファイル: qtest2.py プロジェクト: guaka/py-audio-analysis
    def setArray(self, arr, palette=None, axis_x_max=None, axis_y_max=None):
        self.array = arr
        self.palette = palette or palettes["brownish"]

        s = shape(arr)
        axis_y_max = axis_y_max or s[0]
        axis_x_max = axis_x_max or s[1]

        self.setAxisScale(QwtPlot.xBottom, 0, axis_x_max)
        self.setAxisScale(QwtPlot.yLeft, 0, axis_y_max)
        self.replot()

        # if no_scaling: #for subplots and stuff like that...
        #  im = pilutil.toimage(MLab.flipud(arr), pal = palette, cmin = 0., cmax = 1.)
        self.image = pilutil.toimage(MLab.flipud(arr), pal=self.palette)
        if hasattr(self, "image_unzoomed"):
            self.image_unzoomed = self.image
        self.doPlotImage()

        if self.legend:
            self.legend.setImagePlot(self)
コード例 #5
0
ファイル: qtest2.py プロジェクト: guaka/py-audio-analysis
    def setImagePlot(self, implot, arr=None):
        self.implot = implot
        implot.legend = self

        self.parent_array = arr or implot.array
        self.palette = implot.palette

        r = ravel(self.parent_array)
        r_min, r_max = min(r), max(r)

        dif = r_max - r_min
        if dif == 0:
            r_max = r_min + 1
        self.array = arange(r_min, r_max, dif / 256.)[:, NewAxis]

        self.setAxisScale(QwtPlot.yLeft, r_min, r_max)
        self.replot()

        # if no_scaling: #for subplots and stuff like that...
        #  im = pilutil.toimage(MLab.flipud(arr), pal = palette, cmin = 0., cmax = 1.)
        self.image = pilutil.toimage(MLab.flipud(self.array), pal=self.palette)
        self.doPlotImage()
コード例 #6
0
ファイル: qtest2.py プロジェクト: guaka/py-audio-analysis
 def zoom(self, x0, y0, x1, y1):
     x0, y0, x1, y1 = map(int, (x0, y0, x1, y1))
     if not self.rescale_on_zoom:
         if not hasattr(self, "image_unzoomed"):
             self.image_unzoomed = copy.copy(self.image)
         unz = self.image_unzoomed
         y_top = unz.size[1]
         flip = lambda y: y_top - y
         if y1 > y0:
             y0, y1 = y1, y0
         self.image = copy.copy(unz)
         self.image = self.image.transform(unz.size, Image.EXTENT,
                                           (x0, flip(y0), x1, flip(y1)))
     else:
         if y1 < y0:
             y0, y1 = y1, y0
         #print x0, x1, y0, y1
         #print shape(self.array)
         arr = self.array[y0:y1, x0:x1]
         self.image = pilutil.toimage(MLab.flipud(arr), pal=self.palette)
         if self.legend:
             self.legend.setImagePlot(self, arr)
     self.doPlotImage()
コード例 #7
0
def pseudocolor(M, draw=1):
    """Draws a psuedo-color representation of a matrix.
    
    Comments:
        * Use keyword setting draw=0 to just return the plot object without
            first drawing the plot.
            
        * Routine actually inverts the ordering of the matrix so it is
        viewed as we generally think of matrices (i.e. with row indices
        increasing as we move down, and column indices increasing as we
        move to the right)
    """
    nr, nc = M.shape
    plot = contours.ColorPlot()
    ai = plots.auto_axis(Num.ravel(M))
    plot.axes.zaxis(min = ai.min, max = ai.max, 
                    tickstart = ai.start, tickstep = ai.step)
    plot.axes(autoresolution = (nr,nc))
    clrmatrix = contours.ColorMatrix(MLab.flipud(M), nr, nc)
    plot.add(clrmatrix)
    
    if draw:
        plot.draw()
    return plot