Exemplo n.º 1
0
def makeleg(leg,pos,lenx,dd,theight=12):
    # Place legend
    x0,y0 = pos
    dx,dy = dd
    for k in range(len(leg['txt'])):
        gist.plg([y0+k*dy]*2,[x0,x0+lenx],type=leg['sym'][k][1],marks=0)
        if leg['sym'][k][0] is not None:
            gist.plg([y0+k*dy]*2,[x0,x0+lenx],type='none',marks=1,marker=leg['sym'][k][0])
        if leg['txt'][k] != "":
            gist.plt(leg['txt'][k],x0+lenx+dx,y0+k*dy,height=theight,tosys=1,justify='LH')
    return
Exemplo n.º 2
0
def makeleg(leg,pos,lenx,dd,theight=12):
    # Place legend
    x0,y0 = pos
    dx,dy = dd
    for k in range(len(leg['txt'])):
        gist.plg([y0+k*dy]*2,[x0,x0+lenx],type=leg['sym'][k][1],marks=0)
        if leg['sym'][k][0] is not None:
            gist.plg([y0+k*dy]*2,[x0,x0+lenx],type='none',marks=1,marker=leg['sym'][k][0])
        if leg['txt'][k] != "":
            gist.plt(leg['txt'][k],x0+lenx+dx,y0+k*dy,height=theight,tosys=1,justify='LH')
    return
Exemplo n.º 3
0
def addtext(txt,xy=None,fontsize=16,font='helvetica',color='black',
            orient=0,justify='LA',tosys=0):
    if xy is None:
        result = gist.mouse(0,0,"Click on point for lower left starting position")
        if result is None:
            raise ValueError, "Invalid point entered."
        x,y = result[4],result[5]
        tosys = 0
    else:
        x,y = xy
    if isinstance(txt, type('')) and txt != '':
        gist.plt(txt, x, y, tosys=tosys, justify=justify,
                 height=fontsize,font=font, color=color, orient=orient)
    return
Exemplo n.º 4
0
def addtext(txt,xy=None,fontsize=16,font='helvetica',color='black',
            orient=0,justify='LA',tosys=0):
    if xy is None:
        result = gist.mouse(0,0,"Click on point for lower left starting position")
        if result is None:
            raise ValueError, "Invalid point entered."
        x,y = result[4],result[5]
        tosys = 0
    else:
        x,y = xy
    if isinstance(txt, type('')) and txt != '':
        gist.plt(txt, x, y, tosys=tosys, justify=justify,
                 height=fontsize,font=font, color=color, orient=orient)
    return
Exemplo n.º 5
0
def title3(text,color=None,font='helvetica',fontsize=18,deltax=0.0,deltay=0.0):

    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'

    vp = gist.viewport()
    xmidpt = (vp[0] + vp[1])/2.0 + deltax
    if text != "":
        gist.plt(text,xmidpt,vp[3]-0.05-deltay, font=font, justify='CB',
                 height=fontsize, color=color)
Exemplo n.º 6
0
def title3(text,color=None,font='helvetica',fontsize=18,deltax=0.0,deltay=0.0):

    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'

    vp = gist.viewport()
    xmidpt = (vp[0] + vp[1])/2.0 + deltax
    if text != "":
        gist.plt(text,xmidpt,vp[3]-0.05-deltay, font=font, justify='CB',
                 height=fontsize, color=color)
Exemplo n.º 7
0
def ylabel(text,color=None,font='helvetica',fontsize=16,deltax=0.0,deltay=0.0):
    """To get symbol font for the next character precede by !.  To get
    superscript enclose with ^^
    To get subscript enclose with _<text>_
    """
    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'
    vp = gist.viewport()
    ymidpt = (vp[2] + vp[3])/2.0 + deltay
    x0 = vp[0] - 0.055 + deltax
    if text != "":
        gist.plt(text, x0, ymidpt, color=color,
                 font=font, justify="CB", height=fontsize, orient=1)
    return x0, ymidpt
Exemplo n.º 8
0
def ylabel(text,color=None,font='helvetica',fontsize=16,deltax=0.0,deltay=0.0):
    """To get symbol font for the next character precede by !.  To get
    superscript enclose with ^^
    To get subscript enclose with _<text>_
    """
    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'
    vp = gist.viewport()
    ymidpt = (vp[2] + vp[3])/2.0 + deltay
    x0 = vp[0] - 0.055 + deltax
    if text != "":
        gist.plt(text, x0, ymidpt, color=color,
                 font=font, justify="CB", height=fontsize, orient=1)
    return x0, ymidpt
Exemplo n.º 9
0
def title(text,color=None,font='helvetica',fontsize=18,deltax=0.0,deltay=0.0):
    """Set title for plot.

    To get symbol font for the next character precede by !.  To get
    superscript enclose with ^^
    To get subscript enclose with _<text>_
    """
    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'

    vp = gist.viewport()
    xmidpt = (vp[0] + vp[1])/2.0 + deltax
    if text != "":
        gist.plt(text,xmidpt,vp[3] + 0.02 + deltay, font=font, justify='CB',
                 height=fontsize, color=color)
Exemplo n.º 10
0
def title(text,color=None,font='helvetica',fontsize=18,deltax=0.0,deltay=0.0):
    """Set title for plot.

    To get symbol font for the next character precede by !.  To get
    superscript enclose with ^^
    To get subscript enclose with _<text>_
    """
    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'

    vp = gist.viewport()
    xmidpt = (vp[0] + vp[1])/2.0 + deltax
    if text != "":
        gist.plt(text,xmidpt,vp[3] + 0.02 + deltay, font=font, justify='CB',
                 height=fontsize, color=color)
Exemplo n.º 11
0
def matview(A,cmax=None,cmin=None,palette=None,color='black'):
    """Plot an image of a matrix.
    """
    A = Numeric.asarray(A)
    if A.dtype.char in ['D','F']:
        print "Warning: complex array given, plotting magnitude."
        A = abs(A)
    M,N = A.shape
    A = A[::-1,:]
    if cmax is None:
        cmax = max(ravel(A))
    if cmin is None:
        cmin = min(ravel(A))
    cmax = float(cmax)
    cmin = float(cmin)
    byteimage = gist.bytscl(A,cmin=cmin,cmax=cmax)
    change_palette(palette)
    gist.window(style='nobox.gs')
    _current_style='nobox.gs'
    gist.pli(byteimage)
    old_vals = gist.limits(square=1)
    vals = gist.limits(square=1)
    if color is None:
        return
    vp = gist.viewport()
    axv,bxv,ayv,byv = vp
    axs,bxs,ays,bys = vals[:4]
    # bottom left corner column
    posy = -ays*(byv-ayv)/(bys-ays) + ayv
    posx = -axs*(bxv-axv)/(bxs-axs) + axv
    gist.plt('b',posx,posy-0.005,justify='LT',color=color)
    # bottom left corner row
    gist.plt(str(M),posx-0.005,posy,justify='RB',color=color)
    # top left corner row
    posy = (M-ays)*(byv-ayv)/(bys-ays) + ayv
    gist.plt('b',posx-0.005,posy,justify='RT',color=color)
    # bottom right column
    posy = -ays*(byv-ayv)/(bys-ays) + ayv
    posx = (N-axs)*(bxv-axv)/(bxs-axs) + axv
    gist.plt(str(N),posx,posy-0.005,justify='RT',color=color)
Exemplo n.º 12
0
def matview(A,cmax=None,cmin=None,palette=None,color='black'):
    """Plot an image of a matrix.
    """
    A = numpy.asarray(A)
    if A.dtype.char in ['D','F']:
        print "Warning: complex array given, plotting magnitude."
        A = abs(A)
    M,N = A.shape
    A = A[::-1,:]
    if cmax is None:
        cmax = max(ravel(A))
    if cmin is None:
        cmin = min(ravel(A))
    cmax = float(cmax)
    cmin = float(cmin)
    byteimage = gist.bytscl(A,cmin=cmin,cmax=cmax)
    change_palette(palette)
    gist.window(style='nobox.gs')
    _current_style='nobox.gs'
    gist.pli(byteimage)
    old_vals = gist.limits(square=1)
    vals = gist.limits(square=1)
    if color is None:
        return
    vp = gist.viewport()
    axv,bxv,ayv,byv = vp
    axs,bxs,ays,bys = vals[:4]
    # bottom left corner column
    posy = -ays*(byv-ayv)/(bys-ays) + ayv
    posx = -axs*(bxv-axv)/(bxs-axs) + axv
    gist.plt('b',posx,posy-0.005,justify='LT',color=color)
    # bottom left corner row
    gist.plt(str(M),posx-0.005,posy,justify='RB',color=color)
    # top left corner row
    posy = (M-ays)*(byv-ayv)/(bys-ays) + ayv
    gist.plt('b',posx-0.005,posy,justify='RT',color=color)
    # bottom right column
    posy = -ays*(byv-ayv)/(bys-ays) + ayv
    posx = (N-axs)*(bxv-axv)/(bxs-axs) + axv
    gist.plt(str(N),posx,posy-0.005,justify='RT',color=color)
Exemplo n.º 13
0
def legend(text,linetypes=None,lleft=None,color=None,tfont='helvetica',fontsize=14,nobox=0):
    """Construct and place a legend.

    Description:

      Build a legend and place it on the current plot with an interactive
      prompt.

    Inputs:

      text -- A list of strings which document the curves.
      linetypes -- If not given, then the text strings are associated
                   with the curves in the order they were originally
                   drawn.  Otherwise, associate the text strings with the
                   corresponding curve types given.  See plot for description.

    """
    global _hold
    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'

    sys = gist.plsys()
    if sys == 0:
        gist.plsys(1)
    viewp = gist.viewport()
    gist.plsys(sys)
    DX = viewp[1] - viewp[0]
    DY = viewp[3] - viewp[2]
    width = DY / 10.0;
    if lleft is None:
        lleft = gist.mouse(0,0,"Click on point for lower left coordinate.")
        llx = lleft[0]
        lly = lleft[1]
    else:
        llx,lly = lleft[:2]

    savesys = gist.plsys()
    dx = width / 3.0
    legarr = Numeric.arange(llx,llx+width,dx)
    legy = Numeric.ones(legarr.shape)
    dy = fontsize*points*1.2
    deltay = fontsize*points / 2.8
    deltax = fontsize*points / 2.6 * DX / DY
    ypos = lly + deltay;
    if linetypes is None:
        linetypes = _GLOBAL_LINE_TYPES[:]  # copy them out
    gist.plsys(0)
    savehold = _hold
    _hold = 1
    for k in range(len(text)):
        plot(legarr,ypos*legy,linetypes[k])
        print linetypes[k], text[k]
        print llx+width+deltax, ypos-deltay
        if text[k] != "":
            gist.plt(text[k],llx+width+deltax,ypos-deltay,
                     color=color,font=tfont,height=fontsize,tosys=0)
        ypos = ypos + dy
    _hold = savehold
    if nobox:
        pass
    else:
        gist.plsys(0)
        maxlen = MLab.max(map(len,text))
        c1 = (llx-deltax,lly-deltay)
        c2 = (llx + width + deltax + fontsize*points* maxlen/1.8 + deltax,
              lly + len(text)*dy)
        linesx0 = [c1[0],c1[0],c2[0],c2[0]]
        linesy0 = [c1[1],c2[1],c2[1],c1[1]]
        linesx1 = [c1[0],c2[0],c2[0],c1[0]]
        linesy1 = [c2[1],c2[1],c1[1],c1[1]]
        gist.pldj(linesx0,linesy0,linesx1,linesy1,color=color)
    gist.plsys(savesys)
    return
Exemplo n.º 14
0
def legend(text,linetypes=None,lleft=None,color=None,tfont='helvetica',fontsize=14,nobox=0):
    """Construct and place a legend.

    Description:

      Build a legend and place it on the current plot with an interactive
      prompt.

    Inputs:

      text -- A list of strings which document the curves.
      linetypes -- If not given, then the text strings are associated
                   with the curves in the order they were originally
                   drawn.  Otherwise, associate the text strings with the
                   corresponding curve types given.  See plot for description.

    """
    global _hold
    global _textcolor
    if color is None:
        color = _textcolor
    else:
        _textcolor = color
    if color is None:
        color = 'black'

    sys = gist.plsys()
    if sys == 0:
        gist.plsys(1)
    viewp = gist.viewport()
    gist.plsys(sys)
    DX = viewp[1] - viewp[0]
    DY = viewp[3] - viewp[2]
    width = DY / 10.0;
    if lleft is None:
        lleft = gist.mouse(0,0,"Click on point for lower left coordinate.")
        llx = lleft[0]
        lly = lleft[1]
    else:
        llx,lly = lleft[:2]

    savesys = gist.plsys()
    dx = width / 3.0
    legarr = numpy.arange(llx,llx+width,dx)
    legy = numpy.ones(legarr.shape)
    dy = fontsize*points*1.2
    deltay = fontsize*points / 2.8
    deltax = fontsize*points / 2.6 * DX / DY
    ypos = lly + deltay;
    if linetypes is None:
        linetypes = _GLOBAL_LINE_TYPES[:]  # copy them out
    gist.plsys(0)
    savehold = _hold
    _hold = 1
    for k in range(len(text)):
        plot(legarr,ypos*legy,linetypes[k])
        print linetypes[k], text[k]
        print llx+width+deltax, ypos-deltay
        if text[k] != "":
            gist.plt(text[k],llx+width+deltax,ypos-deltay,
                     color=color,font=tfont,height=fontsize,tosys=0)
        ypos = ypos + dy
    _hold = savehold
    if nobox:
        pass
    else:
        gist.plsys(0)
        maxlen = numpy.max(map(len,text))
        c1 = (llx-deltax,lly-deltay)
        c2 = (llx + width + deltax + fontsize*points* maxlen/1.8 + deltax,
              lly + len(text)*dy)
        linesx0 = [c1[0],c1[0],c2[0],c2[0]]
        linesy0 = [c1[1],c2[1],c2[1],c1[1]]
        linesx1 = [c1[0],c2[0],c2[0],c1[0]]
        linesy1 = [c2[1],c2[1],c1[1],c1[1]]
        gist.pldj(linesx0,linesy0,linesx1,linesy1,color=color)
    gist.plsys(savesys)
    return