def plot2d(z, x=None, y=None, title=None, rangex=None, rangey=None, \ rangez=None, labx='', laby='', rangex2=None, rangey2=None, \ labx2='', laby2='', image=ppgplot_palette_, contours=None, \ logx=0, logy=0, logx2=0, logy2=0, \ line=ppgplot_linestyle_, width=ppgplot_linewidth_, \ color=ppgplot_color_, labels=ppgplot_labels_, \ labelint=ppgplot_labelint_, labelmin=ppgplot_labelmin_, \ font=ppgplot_font_, id=0, noscale=0, aspect=1, \ fontsize=ppgplot_font_size_, ticks='out', panels=[1,1], \ device=ppgplot_device_): """ plot2d(z, ...) An interface to make various 2D plots using PGPLOT. 'z' is the 2D Numpy array to be plotted. The optional entries are: x: x values (default = 0, 1, ...) y: y values (default = 0, 1, ...) title: graph title (default = None) rangex: range for the x-axis (default = automatic) rangey: range for the y-axis (default = automatic) rangez: range for the z-axis (default = automatic) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: range for 2nd x-axis (default = None) rangey2: range for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) image: color palette for image (default = 'rainbow') contours: list of contour values (default = None) line: contour line style (default = 1 (solid)) width: contour line width (default = 1 (thin)) color: contour line color (default = 'white') labels: color of contour labels (default = None) labelint: contour label spacing (default = 20) labelmin: min contour label spacing (default = 20) font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: show ID line on plot (default = 0 (no)) noscale: turn off auto scaling (default = 0 (no)) aspect: Aspect ratio (default = 1 (square)) ticks: Ticks point in or out (default = 'out') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ # Make sure the input data is a 2D array z = Num.asarray(z); if not len(z.shape)==2: print 'Input data array must be 2 dimensional.' return # Announce the global variables we will be using global ppgplot_dev_open_, ppgplot_dev_prep_, pgpalette # Define the X and Y axis limits if needed if x is None: x=Num.arange(z.shape[1], dtype='f') else: x = Num.asarray(x) if y is None: y=Num.arange(z.shape[0], dtype='f') else: y = Num.asarray(y) # Determine the scaling to use for the axes if rangex is None: rangex=[Num.minimum.reduce(x), \ Num.maximum.reduce(x)] if rangey is None: rangey=[Num.minimum.reduce(y), \ Num.maximum.reduce(y)] if rangez is None: rangez=[Num.minimum.reduce(Num.ravel(z)), \ Num.maximum.reduce(Num.ravel(z))] # Prep the plotting device... if (not ppgplot_dev_prep_): prepplot(rangex, rangey, title, labx, laby, \ rangex2, rangey2, labx2, laby2, logx, logy, \ logx2, logy2, font, fontsize, id, aspect, \ ticks, panels, device=device) if image is not None: # Set the color indices and the color table lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l,pgpalette.r,pgpalette.g,pgpalette.b) # Construct the image ppgplot.pgimag_s(z, 0.0, 0.0, rangex[0], rangey[0], \ rangex[1], rangey[1]) reset_colors() if contours is not None: contours = Num.asarray(contours) # Choose the line style ppgplot.pgsls(line) # Choose the line width ppgplot.pgslw(width) # Choose the line color for the contourlines if type(color) == types.StringType: ppgplot.pgsci(ppgplot_colors_[color]) else: ppgplot.pgsci(color) # Construct the contours ppgplot.pgcont_s(z, len(contours), contours, rangex[0], \ rangey[0], rangex[1], rangey[1]) # Label the contours if requested if labels is not None: # Choose the line color for the contourlines if type(labels) == types.StringType: ppgplot.pgsci(ppgplot_colors_[labels]) else: ppgplot.pgsci(labels) for i in range(len(contours)): ppgplot.pgconl_s(z, contours[i], str(contours[i]), labelint, labelmin)
def plot2d(z, x=None, y=None, title=None, rangex=None, rangey=None, \ rangez=None, labx='', laby='', rangex2=None, rangey2=None, \ labx2='', laby2='', image=ppgplot_palette_, contours=None, \ logx=0, logy=0, logx2=0, logy2=0, \ line=ppgplot_linestyle_, width=ppgplot_linewidth_, \ color=ppgplot_color_, labels=ppgplot_labels_, \ labelint=ppgplot_labelint_, labelmin=ppgplot_labelmin_, \ font=ppgplot_font_, id=0, noscale=0, aspect=1, \ fontsize=ppgplot_font_size_, ticks='out', panels=[1,1], \ device=ppgplot_device_): """ plot2d(z, ...) An interface to make various 2D plots using PGPLOT. 'z' is the 2D Numpy array to be plotted. The optional entries are: x: x values (default = 0, 1, ...) y: y values (default = 0, 1, ...) title: graph title (default = None) rangex: range for the x-axis (default = automatic) rangey: range for the y-axis (default = automatic) rangez: range for the z-axis (default = automatic) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: range for 2nd x-axis (default = None) rangey2: range for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) image: color palette for image (default = 'rainbow') contours: list of contour values (default = None) line: contour line style (default = 1 (solid)) width: contour line width (default = 1 (thin)) color: contour line color (default = 'white') labels: color of contour labels (default = None) labelint: contour label spacing (default = 20) labelmin: min contour label spacing (default = 20) font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: show ID line on plot (default = 0 (no)) noscale: turn off auto scaling (default = 0 (no)) aspect: Aspect ratio (default = 1 (square)) ticks: Ticks point in or out (default = 'out') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ # Make sure the input data is a 2D array z = Num.asarray(z) if not len(z.shape) == 2: print 'Input data array must be 2 dimensional.' return # Announce the global variables we will be using global ppgplot_dev_open_, ppgplot_dev_prep_, pgpalette # Define the X and Y axis limits if needed if x is None: x = Num.arange(z.shape[1], dtype='f') else: x = Num.asarray(x) if y is None: y = Num.arange(z.shape[0], dtype='f') else: y = Num.asarray(y) # Determine the scaling to use for the axes if rangex is None: dx = x[-1] - x[-2] rangex = [x[0], x[-1] + dx] if rangey is None: dy = y[-1] - y[-2] rangey = [y[0], y[-1] + dy] if rangez is None: rangez=[Num.minimum.reduce(Num.ravel(z)), \ Num.maximum.reduce(Num.ravel(z))] # Prep the plotting device... if (not ppgplot_dev_prep_): prepplot(rangex, rangey, title, labx, laby, \ rangex2, rangey2, labx2, laby2, logx, logy, \ logx2, logy2, font, fontsize, id, aspect, \ ticks, panels, device=device) if image is not None: # Set the color indices and the color table lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b) # Construct the image ppgplot.pgimag_s(z, 0.0, 0.0, rangex[0], rangey[0], \ rangex[1], rangey[1]) reset_colors() if contours is not None: contours = Num.asarray(contours) # Choose the line style ppgplot.pgsls(line) # Choose the line width ppgplot.pgslw(width) # Choose the line color for the contourlines if type(color) == types.StringType: ppgplot.pgsci(ppgplot_colors_[color]) else: ppgplot.pgsci(color) # Construct the contours ppgplot.pgcont_s(z, len(contours), contours, rangex[0], \ rangey[0], rangex[1], rangey[1]) # Label the contours if requested if labels is not None: # Choose the line color for the contourlines if type(labels) == types.StringType: ppgplot.pgsci(ppgplot_colors_[labels]) else: ppgplot.pgsci(labels) for i in range(len(contours)): ppgplot.pgconl_s(z, contours[i], str(contours[i]), labelint, labelmin)
ppgplot.pgbox("BCNST", 0.0, 0, "BCST", 0.0, 0) ppgplot.pgline(fdotcut, zs) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, "Relative Power") # f-fdot image ppgplot.pgsvp(margin, margin + imfract, margin, margin + imfract) ppgplot.pgswin(min(rs), max(rs), min(zs), max(zs)) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, labx) ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, laby) lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b) ppgplot.pgimag_s(pffdot, 0.0, 0.0, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgsci(1) ppgplot.pgcont_s(pffdot, len(contours), contours, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgbox("BCST", 0.0, 0, "BCST", 0.0, 0) ppgplot.pgsci(1) ppgplot.pgbox("N", 0.0, 0, "N", 0.0, 0) # gray axes ppgplot.pgscr(1, 0.5, 0.5, 0.5) ppgplot.pgsci(1) ppgplot.pgslw(2) ppgplot.pgline(rgx, num.asarray([0.0, 0.0])) ppgplot.pgline(num.asarray([0.0, 0.0]), rgy) ppgplot.pgclos()
ppgplot.pgline(fdotcut, zs) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, "Relative Power") # f-fdot image ppgplot.pgsvp(margin, margin + imfract, margin, margin + imfract) ppgplot.pgswin(min(rs), max(rs), min(zs), max(zs)) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, labx) ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, laby) lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b) ppgplot.pgimag_s(pvol[ii], 0.0, 0.0, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgsci(1) ppgplot.pgcont_s(pvol[ii], len(contours), contours, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgbox("BCST", 0.0, 0, "BCST", 0.0, 0) ppgplot.pgsci(1) ppgplot.pgbox("N", 0.0, 0, "N", 0.0, 0) # gray axes ppgplot.pgscr(1, 0.5, 0.5, 0.5) ppgplot.pgsci(1) ppgplot.pgslw(2) ppgplot.pgline(rgx, num.asarray([0.0, 0.0])) ppgplot.pgline(num.asarray([0.0, 0.0]), rgy) time.sleep(0.1) if device == "/XWIN": ppgplot.pgeras() else:
ppgplot.pgline(fdotcut, zs) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, "Relative Power"); # f-fdot image ppgplot.pgsvp(margin, margin+imfract, margin, margin+imfract) ppgplot.pgswin(min(rs), max(rs), min(zs), max(zs)) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, labx); ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, laby); lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b) ppgplot.pgimag_s(pffdot, 0.0, 0.0, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgsci(1) ppgplot.pgcont_s(pffdot, len(contours), contours, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgbox("BCST", 0.0, 0, "BCST", 0.0, 0) ppgplot.pgsci(1) ppgplot.pgbox("N", 0.0, 0, "N", 0.0, 0) # gray axes ppgplot.pgscr(1, 0.5, 0.5, 0.5) ppgplot.pgsci(1) ppgplot.pgslw(2) ppgplot.pgline(rgx, num.asarray([0.0, 0.0])) ppgplot.pgline(num.asarray([0.0, 0.0]), rgy) ppgplot.pgclos()
ppgplot.pgline(fdotcut, zs) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, "Relative Power"); # f-fdot image ppgplot.pgsvp(margin, margin+imfract, margin, margin+imfract) ppgplot.pgswin(min(rs), max(rs), min(zs), max(zs)) ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, labx); ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, laby); lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b) ppgplot.pgimag_s(pvol[ii], 0.0, 0.0, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgsci(1) ppgplot.pgcont_s(pvol[ii], len(contours), contours, rgx[0], rgy[0], rgx[1], rgy[1]) ppgplot.pgbox("BCST", 0.0, 0, "BCST", 0.0, 0) ppgplot.pgsci(1) ppgplot.pgbox("N", 0.0, 0, "N", 0.0, 0) # gray axes ppgplot.pgscr(1, 0.5, 0.5, 0.5) ppgplot.pgsci(1) ppgplot.pgslw(2) ppgplot.pgline(rgx, num.asarray([0.0, 0.0])) ppgplot.pgline(num.asarray([0.0, 0.0]), rgy) time.sleep(0.1) if device=="/XWIN": ppgplot.pgeras() else: