Esempio n. 1
0
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()
Esempio n. 2
0
 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)
Esempio n. 3
0
    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()
Esempio n. 4
0
    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)
Esempio n. 5
0
    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()
Esempio n. 6
0
 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()
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