def init_xyplot(fd_fff):

    xx = [0.0] * 20     #float xx[ 20 ],
    yy = [0.0] * 20     #yy[ 20 ];

    #for ( i = 0; i <= 10; i++ )
    for i in range(0, 10+1):
        xx[i] = float(i)
        yy[i] = math.exp( - (xx[i] - 5) * (xx[i] - 5) / 8)

    xfl.fl_set_xyplot_data(fd_fff.xyplot, xx, yy, 8, "Plot Title", \
            "X-Axis", "Y|Axis")
    xfl.fl_set_xyplot_ybounds(fd_fff.xyplot, 0, 1.1)
    xfl.fl_set_xyplot_xbounds(fd_fff.xyplot, 0, 10)
    xfl.fl_add_xyplot_overlay(fd_fff.xyplot, 1, xx, yy, 11, xfl.FL_YELLOW)
    xfl.fl_set_xyplot_overlay_type(fd_fff.xyplot, 1, xfl.FL_LINEPOINTS_XYPLOT)
    xfl.fl_set_xyplot_interpolate(fd_fff.xyplot, 1, 2, 0.1)

    xfl.fl_add_xyplot_text(fd_fff.xyplot, 0.5, 1.0, "Gaussian\nDistribution", \
            xfl.FL_ALIGN_RIGHT, xfl.FL_WHITE)

    xfl.fl_set_xyplot_key(fd_fff.xyplot, 0, "Original")
    xfl.fl_set_xyplot_key(fd_fff.xyplot, 1, "Overlay")
    xfl.fl_set_xyplot_key_position(fd_fff.xyplot, 9.8, 1.08, \
            xfl.FL_ALIGN_LEFT_BOTTOM)
def bounds_cb(pobj, data):
    # char buf[ 50 ]

    if not data:
        xmin = float(xfl.fl_get_input(xypui.xmin))
        xmax = float(xfl.fl_get_input(xypui.xmax))

        if xmin <= 0.0:
            xmin = 1.0
            xfl.fl_set_input(xypui.xmin, "1.0")

        if xmax <= 0.0:
            xmax = 10.0
            xfl.fl_set_input(xypui.xmax, "10.0")

        xfl.fl_set_xyplot_xbounds(xypui.xyplot, xmin, xmax)

        xmin, xmax = xfl.fl_get_xyplot_xbounds(xypui.xyplot)
        #sprintf( buf, "%g", xmin );
        buf = str(xmin)
        xfl.fl_set_input(xypui.xmin, buf)
        #sprintf( buf, "%g", xmax );
        buf = str(xmax)
        xfl.fl_set_input(xypui.xmax, buf)

    else:
        ymin = float(xfl.fl_get_input(xypui.ymin))
        ymax = float(xfl.fl_get_input(xypui.ymax))

        if ymin <= 0.0:
            ymin = 1.0
            xfl.fl_set_input(xypui.ymin, "1.0")

        if ymax <= 0.0:
            ymax = 10.0
            xfl.fl_set_input(xypui.ymax, "10.0")

        xfl.fl_set_xyplot_ybounds(xypui.xyplot, ymin, ymax)

        ymin, ymax = xfl.fl_get_xyplot_ybounds(xypui.xyplot)
        #sprintf( buf, "%g", ymin );
        buf = str(ymin)
        xfl.fl_set_input(xypui.ymin, buf)
        #sprintf( buf, "%g", ymax );
        buf = str(ymax)
        xfl.fl_set_input(xypui.ymax, buf)
def main(lsysargv, sysargv):
    global xyplot

    xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0)
    create_form_xyplot()

    # Make sure double buffer also works

    for i in range(0, N):

        xfl.fl_set_object_dblbuffer(xyplot[i], 1)

        for j in range(0, 21):
            x[i][j] = j * 3.1415 / 10 + 0.2
            y[i][j] = math.sin(2 * x[i][j]) + math.cos(x[i][j])

        xfl.fl_set_xyplot_data(xyplot[i], x[i], y[i], 21, "TestTitle", \
                "X-axis", "Y|axis")
        if i == 0:
            xfl.fl_add_xyplot_text(xyplot[i], x[i][15], 0.1, \
                    "@2->", xfl.FL_ALIGN_TOP, xfl.FL_BLUE)
        else:
            xfl.fl_add_xyplot_text(xyplot[i], x[i][8], 1.4, \
                    "Text Inset", xfl.FL_ALIGN_CENTER, xfl.FL_BLUE)

        if i == 3:
            xfl.fl_set_xyplot_xgrid(xyplot[i], xfl.FL_GRID_MAJOR)
            xfl.fl_set_xyplot_xgrid(xyplot[i], xfl.FL_GRID_MINOR)
        elif i == 0:
            xfl.fl_set_xyplot_xtics(xyplot[i], 7, 2)
            xfl.fl_set_xyplot_xbounds(xyplot[i], 6, 0)
        elif i == 1:
            xfl.fl_set_xyplot_ytics(xyplot[i], 5, 2)
            xfl.fl_set_xyplot_ybounds(xyplot[i], 2.4, -2.4)

        xfl.fl_set_object_posthandler(xyplot[i], post)

    xfl.fl_show_form( fxyplot, xfl.FL_PLACE_MOUSE | xfl.FL_FREE_SIZE, \
            xfl.FL_TRANSIENT, "XYplot")

    while xfl.fl_do_forms():
        pass

    return 0
def main(lsysargv, sysargv):
    global xypui

    x = [0.0] * 11
    y = [0.0] * 11

    xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0)
    xypui = create_form_axypform()

    # Fill-in form initialization code

    xfl.fl_set_xyplot_ybounds(xypui.xyplot, 1.0, 10.0)
    for i in range(0, 11):
        x[i] = y[i] = float(i) + 1


    xfl.fl_add_xyplot_overlay(xypui.xyplot, 1, x, y, 10, xfl.FL_YELLOW)
    xfl.fl_set_xyplot_overlay_type(xypui.xyplot, 1, xfl.FL_LINEPOINTS_XYPLOT)
    xfl.fl_set_xyplot_interpolate(xypui.xyplot, 1, 2, 0.1)

    #srand( time( NULL ) );
    random.seed(None)

    RAND_MAX = xfl.INT_MAX
    for i in range(0, 10):
        y[i] += float(random.random() / RAND_MAX - 0.5)

    xfl.fl_set_xyplot_data(xypui.xyplot, x, y, 11, \
            "Active (log) xyplot with overlay", "x-axis", "y-axis")
    xfl.fl_set_xyplot_linewidth(xypui.xyplot, 0, 2)
    xfl.fl_set_xyplot_xgrid(xypui.xyplot, xfl.FL_GRID_MINOR)

    # Show the first form

    xfl.fl_show_form(xypui.axypform, xfl.FL_PLACE_MOUSE | xfl.FL_FREE_SIZE,
            xfl.FL_FULLBORDER, "xyplotactivelog")

    xfl.fl_do_forms()

    return 0