[ialblshow] [Up] [iasplot] Visualization

iaplot
Plot a function.

Synopsis

g, d = iaplot( x = 0, y = None, filename = None )

Implemented in Python.

Input

x Image. Gray-scale (uint8 or uint16) or binary image (logical).

x.

Default: 0

y Image. Gray-scale (uint8 or uint16) or binary image (logical).

f(x).

Default: None

filename String.

Name of the postscript file.

Default: None

Output

g String.

Gnuplot pointer.

d String.

Gnuplot data.

Description

Plot a 2D function y=f(x).

Examples

>>> import Numeric

              
>>> x = Numeric.arange(0, 2*Numeric.pi, 0.1)

              
>>> y = Numeric.sin(x)

              
>>> g, d = iaplot(x,y)
>>> g('set data style impulses')

              
>>> g('set grid')

              
>>> g('set xlabel "X values" -20,0')

              
>>> g('set ylabel "Y values"')

              
>>> g('set title "Example Plot"')

              
>>> g.plot(d, 'cos(x)')
>>> 
x,y d, 'cos(x)'

Source Code

def iaplot(x=0, y=None, filename=None):
    import Numeric
    try:
        import Gnuplot
        g = Gnuplot.Gnuplot(debug=1)
        g('set data style lines')
        x = Numeric.ravel(x)
        if not y:
            y = x
            x = Numeric.arange(len(y))
        else:
            y = Numeric.ravel(y)
        d = Gnuplot.Data(x, y)
        g.plot(d)
        if filename:
            g.hardcopy(filename, mode='portrait', enhanced=1, color=1)
    except:
        g,d = None,None
    return g, d
    
[ialblshow] [Up] [iasplot] http://www.python.org