To create a curve in a Rappture C program, we make people do something like this:


    rpPutString (   lib,
                    "Fermi-Dirac Factor",
                    RPLIB_OVERWRITE );
    rpPutString (   lib,
                    "Fermi-Dirac Factor",
                    RPLIB_OVERWRITE );
    rpPutString (   lib,
                    RPLIB_OVERWRITE );
    rpPutString (   lib,
                    RPLIB_OVERWRITE );

    while (E < Emax) {
        f = 1.0/(1.0 + exp((E - Ef)/kT));
        sprintf(line,"%f %f\n",f, E);
        rpPutString(lib,"output.curve(f12).component.xy", line, RPLIB_APPEND);
        E = E + dE;


Using RpCurve Object with accessor functions:

    size_t i = 0;
    size_t cnt = (Emax - E)/dE;
    double *f = (double*) malloc(cnt*sizeof(double));
    double *En = (double*) malloc(cnt*sizeof(double));
    RpCurve *c = (RpCurve*) malloc(sizeof(RpCurve));

    // assume allocation succeeded

    // register the object so lib can keep track of it, set a call back/notifier

    // annotate the curve
    rpCurve_title(c,"Fermi-Dirac Factor")
    rpCurve_xlabel(c,"Fermi-Dirac Factor");

    while (E < Emax) {
        f[i] = 1.0/(1.0 + exp((E - Ef)/kT));
        En[i] = E;
        E = E + dE;

    // plot the value from the arrays

    if (c) {
        c = NULL;

    if (f) {
        f = NULL;

    if (En) {
        En = NULL;


The accessor functions can be replaced with annotate functions:

    rpCurve_annotate(c,"title","Fermi-Dirac Factor");
    rpCurve_annotate(c,"xlabel","Fermi-Dirac Factor");

Internally, the RpCurve object should have a hash of curve properties.
Curve Properties:

  • path - full xml path of the object.
  • name - name or id of the curve. This text is displayed when scrolling over the xy plot, or searching for a specific curve.
  • title - title of the plot. Text to be displayed in the Results drop down menu in the gui.
  • xlabel - label of the x axis.
  • xunits - units of values along the x axis.
  • xscale - scale of the x axis. one of linear,log.
  • ylabel - label of the y axis.
  • yunits - units of values along the y axis.
  • yscale - scale of the y axis. one of linear,log.
  • color - color of the curve.
  • marker - type of marker to use.
  • type - type of curve. one of column,bar,area,line(default),xyscatter,xyerror.
  • group - grouping curves so they show up on the same graph.

Curve Accessor functions:

  • int rpCurve_path(RpCurve *c, const char *val);
  • int rpCurve_name(RpCurve *c, const char *val);
  • int rpCurve_title(RpCurve *c, const char *val);
  • int rpCurve_xlabel(RpCurve *c, const char *val);
  • int rpCurve_xunits(RpCurve *c, const char *val);
  • int rpCurve_ylabel(RpCurve *c, const char *val);
  • int rpCurve_yunits(RpCurve *c, const char *val);
  • int rpCurve_annotate(RpCurve *c, const char *prop, const char *val);
  • int rpCurve_prop_lookup(RpCurve *c, const char *prop, const char *val);
Last modified 9 years ago Last modified on Aug 4, 2008, 4:05:02 PM