Beispiel #1
0
int main(int argc, char **argv)
{
    AjPFile infile = NULL;
    AjPFile outfile = NULL;
    AjPStr line;
    AjPGraph graphLB = NULL;
    AjPGraphdata xygraph  = NULL;
    AjPGraphdata xygraph2 = NULL;
    AjBool doplot;

    ajint N=0;

    float *xdata = NULL;
    float *ydata = NULL;
    float *V = NULL;
    float *S = NULL;

    float a;
    float b;
    float upperXlimit;
    float upperYlimit;

    float A;
    float B;
    float C;
    float D;
    float xmin;
    float xmax;
    float ymin;
    float ymax;
    float xmin2;
    float xmax2;
    float ymin2;
    float ymax2;

    float Vmax;
    float Km;
    float cutx;
    float cuty;

    float amin = 0.;
    float amax = 0.;
    float bmin = 0.;
    float bmax = 0.;


    embInit("findkm", argc, argv);

    infile  = ajAcdGetInfile("infile");
    outfile = ajAcdGetOutfile ("outfile");
    doplot  = ajAcdGetBoolean("plot");
    graphLB = ajAcdGetGraphxy("graphLB");
    line = ajStrNew();


    /* Determine N by reading infile */

    while(ajReadlineTrim(infile, &line))
        if(ajStrGetLen(line) >0)
	    N++;


    /* only allocate memory to the arrays */

    AJCNEW(xdata, N);
    AJCNEW(ydata, N);
    AJCNEW(S, N);
    AJCNEW(V, N);

    ajFileSeek(infile, 0L, 0);

    N=0;
    while(ajReadlineTrim(infile, &line))
    {
	if(ajStrGetLen(line) > 0)
        {
            sscanf(ajStrGetPtr(line),"%f %f",&S[N],&V[N]);
            if(S[N] > 0.0 && V[N] > 0.0)
            {
                xdata[N] = S[N];
                ydata[N] = S[N]/V[N];
		N++;
            }
        }
    }


    /* find the max and min values for the graph parameters*/
    xmin = (float)0.5*findkm_findmin(xdata, N);
    xmax = (float)1.5*findkm_findmax(xdata, N);
    ymin = (float)0.5*findkm_findmin(ydata, N);
    ymax = (float)1.5*findkm_findmax(ydata, N);

    xmin2 = (float)0.5*findkm_findmin(S, N);
    xmax2 = (float)1.5*findkm_findmax(S, N);
    ymin2 = (float)0.5*findkm_findmin(V, N);
    ymax2 = (float)1.5*findkm_findmax(V, N);



    /*
    ** In case the casted ints turn out to be same number on the axis,
    ** make the max number larger than the min so graph can be seen.
    */

    if((ajint)xmax == (ajint)xmin)
        ++xmax;
    if((ajint)ymax == (ajint)ymin)
        ++ymax;


    if((ajint)xmax2 == (ajint)xmin2)
        ++xmax2;
    if((ajint)ymax2 == (ajint)ymin2)
        ++ymax2;



    /*
    ** Gaussian Elimination for Best-fit curve plotting and
    ** calculating Km and Vmax
    */

    A = findkm_summation(xdata, N);
    B = findkm_summation(ydata, N);

    C = findkm_multisum(xdata, ydata, N);
    D = findkm_multisum(xdata, xdata, N);


    /*
    ** To find the best fit line, Least Squares Fit:    y =ax +b;
    ** Two Simultaneous equations, REARRANGE FOR b
    **
    ** findkm_summation(ydata, N) - findkm_summation(xdata,N)*a - N*b =0;
    ** b = (findkm_summation(ydata,N) - findkm_summation(xdata,N)*a) /  N;
    ** b = (B - A*a)/ N;
    **
    ** C - D*a - A*((B - A*a)/ N) =0;
    ** C - D*a - A*B/N + A*A*a/N =0;
    ** C - A*B/N = D*a - A*A*a/N;
    */

    /* REARRANGE FOR a */

    a = (N*C - A*B)/ (N*D - A*A);
    b = (B - A*a)/ N;

    /*
    ** Equation of Line - Lineweaver burk eqn
    ** 1/V = (Km/Vmax)*(1/S) + 1/Vmax;
    */


    Vmax = 1/a;
    Km = b/a;

    cutx = -1/Km;
    cuty = Km/Vmax;

    /* set limits for last point on graph */

    upperXlimit = findkm_findmax(xdata,N)+3;
    upperYlimit = (upperXlimit)*a + b;

    ajFmtPrintF(outfile, "---Hanes Woolf Plot Calculations---\n");
    ajFmtPrintF(outfile, "Slope of best fit line is a = %.2f\n", a);
    ajFmtPrintF(outfile,"Coefficient in Eqn of line y = ma +b is b "
		"= %.2f\n", b);

    ajFmtPrintF(outfile, "Where line cuts x axis = (%.2f, 0)\n", cutx);
    ajFmtPrintF(outfile, "Where line cuts y axis = (0, %.2f)\n", cuty);
    ajFmtPrintF(outfile, "Limit-point of graph for plot = (%.2f, %.2f)\n\n",
		upperXlimit, upperYlimit);
    ajFmtPrintF(outfile, "Vmax = %.2f, Km = %f\n",Vmax, Km);

    /* draw graphs */

    if(doplot)
    {
	xygraph = ajGraphdataNewI(N);
	ajGraphdataAddXY(xygraph, S, V);
	ajGraphDataAdd(graphLB, xygraph);
	ajGraphdataSetTitleC(xygraph, "Michaelis Menten Plot");
	ajGraphdataSetXlabelC(xygraph, "[S]");
	ajGraphdataSetYlabelC(xygraph, "V");

	ajGraphxySetXstartF(graphLB, 0.0);
	ajGraphxySetXendF(graphLB, xmax2);
	ajGraphxySetYstartF(graphLB, 0.0);
	ajGraphxySetYendF(graphLB, ymax2);
	ajGraphxySetXrangeII(graphLB, (ajint)0.0, (ajint)xmax2);
	ajGraphxySetYrangeII(graphLB, (ajint)0.0, (ajint)ymax2);
	ajGraphdataAddposLine(xygraph, 0.0, 0.0, S[0], V[0], (ajint)BLACK);
	ajGraphxyShowPointsCircle(graphLB, ajTrue);
	ajGraphdataSetMinmax(xygraph,0.0,xmax2,0.0,ymax2);


	ajGraphicsCalcRange(S,N,&amin,&amax);
	ajGraphicsCalcRange(V,N,&bmin,&bmax);
	ajGraphdataSetTruescale(xygraph,amin,amax,bmin,bmax);
	ajGraphdataSetTypeC(xygraph,"2D Plot Float");

	xygraph2 = ajGraphdataNewI(N);
	ajGraphdataAddXY(xygraph2, xdata, ydata);
	ajGraphDataAdd(graphLB, xygraph2);

	ajGraphdataSetTitleC(xygraph2, "Hanes Woolf Plot");
	ajGraphdataSetXlabelC(xygraph2, "[S]");
	ajGraphdataSetYlabelC(xygraph2, "[S]/V");

	ajGraphxySetXstartF(graphLB, cutx);
	ajGraphxySetXendF(graphLB, upperXlimit);
	ajGraphxySetYstartF(graphLB, 0.0);
	ajGraphxySetYendF(graphLB, upperYlimit);
	ajGraphxySetXrangeII(graphLB, (ajint)cutx, (ajint)upperXlimit);
	ajGraphxySetYrangeII(graphLB, (ajint)0.0, (ajint)upperYlimit);

	ajGraphxyShowPointsCircle(graphLB, ajTrue);
	ajGraphdataSetMinmax(xygraph2, cutx,upperXlimit,0.0,upperYlimit);
	ajGraphicsCalcRange(xdata,N,&amin,&amax);
	ajGraphicsCalcRange(ydata,N,&bmin,&bmax);
	ajGraphdataSetTruescale(xygraph2,amin,amax,bmin,bmax);
	ajGraphdataSetTypeC(xygraph2,"2D Plot");



	ajGraphSetTitleC(graphLB,"FindKm");
	ajGraphxySetflagOverlay(graphLB,ajFalse);
	ajGraphxyDisplay(graphLB, ajTrue);
    }

    AJFREE(xdata);
    AJFREE(ydata);

    AJFREE(S);
    AJFREE(V);

    ajFileClose(&infile);
    ajFileClose(&outfile);

    ajGraphxyDel(&graphLB);
    ajStrDel(&line);

    embExit();

    return 0;
}
static void dottup_stretchplot(AjPGraph graph, const AjPList matchlist,
			       const AjPSeq seq1, const AjPSeq seq2,
			       ajint begin1, ajint begin2,
			       ajint end1, ajint end2)
{
    EmbPWordMatch wmp = NULL;
    float xa[1];
    float ya[2];
    AjPGraphdata gdata = NULL;
    AjPStr tit = NULL;
    float x1;
    float y1;
    float x2;
    float y2;
    AjIList iter = NULL;

    tit = ajStrNew();
    ajFmtPrintS(&tit,"%S",ajGraphGetTitleS(graph));


    gdata = ajGraphdataNewI(1);
    xa[0] = (float)begin1;
    ya[0] = (float)begin2;

    ajGraphSetTitleC(graph,ajStrGetPtr(tit));

    ajGraphSetXlabelC(graph,ajSeqGetNameC(seq1));
    ajGraphSetYlabelC(graph,ajSeqGetNameC(seq2));

    ajGraphdataSetTypeC(gdata,"2D Plot Float");
    ajGraphdataSetMinmax(gdata,(float)begin1,(float)end1,(float)begin2,
			   (float)end2);
    ajGraphdataSetTruescale(gdata,(float)begin1,(float)end1,(float)begin2,
			   (float)end2);
    ajGraphxySetXstartF(graph,(float)begin1);
    ajGraphxySetXendF(graph,(float)end1);
    ajGraphxySetYstartF(graph,(float)begin2);
    ajGraphxySetYendF(graph,(float)end2);

    ajGraphxySetXrangeII(graph,begin1,end1);
    ajGraphxySetYrangeII(graph,begin2,end2);


    if(matchlist)
    {
	iter = ajListIterNewread(matchlist);
	while((wmp = ajListIterGet(iter)))
	{
	    x1 = x2 = (float) (wmp->seq1start + begin1);
	    y1 = y2 = (float) (wmp->seq2start + begin2);
	    x2 += (float) wmp->length-1;
	    y2 += (float) wmp->length-1;
	    ajGraphAddLine(graph,x1,y1,x2,y2,0);
	}
	ajListIterDel(&iter);
    }

    ajGraphdataAddXY(gdata,xa,ya);
    ajGraphDataReplace(graph,gdata);


    ajGraphxyDisplay(graph,ajFalse);
    ajGraphicsClose();

    ajStrDel(&tit);

    return;
}
Beispiel #3
0
int main(int argc, char **argv)
{
    AjPList list = NULL;
    AjPSeq seq;
    AjPSeq seq2;
    AjPStr aa0str = 0;
    AjPStr aa1str = 0;
    const char *s1;
    const char *s2;
    char *strret = NULL;
    ajuint i;
    ajuint j;
    ajuint k;
    ajint l;
    ajint abovethresh;
    ajint total;
    ajint starti = 0;
    ajint startj = 0;
    ajint windowsize;
    float thresh;
    AjPGraph graph   = NULL;
    AjPGraph xygraph = NULL;
    float flen1;
    float flen2;
    ajuint len1;
    ajuint len2;

    AjPTime ajtime = NULL;
    time_t tim;
    AjBool boxit=AJTRUE;
    /* Different ticks as they need to be different for x and y due to
       length of string being important on x */
    ajuint acceptableticksx[]=
    {
	1,10,50,100,500,1000,1500,10000,
	500000,1000000,5000000
    };
    ajuint acceptableticks[]=
    {
	1,10,50,100,200,500,1000,2000,5000,10000,15000,
	500000,1000000,5000000
    };
    ajint numbofticks = 10;
    float xmargin;
    float ymargin;
    float ticklen;
    float tickgap;
    float onefifth;
    float k2;
    float max;
    char ptr[10];
    AjPMatrix matrix = NULL;
    ajint** sub;
    AjPSeqCvt cvt;
    AjPStr  subt = NULL;

    ajint b1;
    ajint b2;
    ajint e1;
    ajint e2;
    AjPStr se1;
    AjPStr se2;
    ajint ithresh;
    AjBool stretch;
    PPoint ppt = NULL;
    float xa[1];
    float ya[1];
    AjPGraphdata gdata=NULL;
    AjPStr tit   = NULL;
    AjIList iter = NULL;
    float x1 = 0.;
    float x2 = 0.;
    float y1 = 0.;
    float y2 = 0.;
    ajuint tui;
    
    se1 = ajStrNew();
    se2 = ajStrNew();

    embInit("dotmatcher", argc, argv);
    
    seq        = ajAcdGetSeq("asequence");
    seq2       = ajAcdGetSeq("bsequence");
    stretch    = ajAcdGetToggle("stretch");
    graph      = ajAcdGetGraph("graph");
    xygraph    = ajAcdGetGraphxy("xygraph");
    windowsize = ajAcdGetInt("windowsize");
    ithresh    = ajAcdGetInt("threshold");
    matrix     = ajAcdGetMatrix("matrixfile");
    
    sub = ajMatrixGetMatrix(matrix);
    cvt = ajMatrixGetCvt(matrix);
    
    thresh = (float)ithresh;

    ajtime = ajTimeNew();

    tim = time(0);
    ajTimeSetLocal(ajtime, tim);
    
    b1 = ajSeqGetBegin(seq);
    b2 = ajSeqGetBegin(seq2);
    e1 = ajSeqGetEnd(seq);
    e2 = ajSeqGetEnd(seq2);
    len1 = ajSeqGetLen(seq);
    len2 = ajSeqGetLen(seq2);
    tui   = ajSeqGetLen(seq);
    flen1 = (float) tui;
    tui   = ajSeqGetLen(seq2);
    flen2 = (float) tui;
    
    ajStrAssignSubC(&se1,ajSeqGetSeqC(seq),b1-1,e1-1);
    ajStrAssignSubC(&se2,ajSeqGetSeqC(seq2),b2-1,e2-1);
    ajSeqAssignSeqS(seq,se1);
    ajSeqAssignSeqS(seq2,se2);
    
    
    s1 = ajStrGetPtr(ajSeqGetSeqS(seq));
    s2 = ajStrGetPtr(ajSeqGetSeqS(seq2));
    
    
    aa0str = ajStrNewRes(1+len1); /* length plus trailing blank */
    aa1str = ajStrNewRes(1+len2);
    
    list = ajListNew();
    
    
    for(i=0;i<len1;i++)
	ajStrAppendK(&aa0str,(char)ajSeqcvtGetCodeK(cvt, *s1++));
    
    for(i=0;i<len2;i++)
	ajStrAppendK(&aa1str,(char)ajSeqcvtGetCodeK(cvt, *s2++));
    
    max = (float)len1;
    if(len2 > max)
	max = (float) len2;
    
    xmargin = ymargin = max *(float)0.15;
    ticklen = xmargin*(float)0.1;
    onefifth  = xmargin*(float)0.2;
    
    subt = ajStrNewC((strret=
		      ajFmtString("(windowsize = %d, threshold = %3.2f  %D)",
				  windowsize,thresh,ajtime)));
    
    

    if(!stretch)
    {
	if( ajStrGetLen(ajGraphGetSubtitleS(graph)) <=1)
	    ajGraphSetSubtitleS(graph,subt);

	ajGraphOpenWin(graph, (float)0.0-ymargin,(max*(float)1.35)+ymargin,
		       (float)0.0-xmargin,(float)max+xmargin);

	ajGraphicsDrawposTextAtmid(flen1*(float)0.5,
                                   (float)0.0-(xmargin/(float)2.0),
		       ajGraphGetXlabelC(graph));
	ajGraphicsDrawposTextAtlineJustify((float)0.0-(xmargin*(float)0.75),
                                           flen2*(float)0.5,
			(float)0.0-(xmargin*(float)0.75),flen1,
			ajGraphGetYlabelC(graph),0.5);

	ajGraphicsSetCharscale(0.5);
    }
    
    
    
    s1= ajStrGetPtr(aa0str);
    s2 = ajStrGetPtr(aa1str);
    
    for(j=0; (ajint)j < (ajint)len2-windowsize;j++)
    {
	i =0;
	total = 0;
	abovethresh =0;

	k = j;
	for(l=0;l<windowsize;l++)
	    total = total + sub[(ajint)s1[i++]][(ajint)s2[k++]];

	if(total >= thresh)
	{
	    abovethresh=1;
	    starti = i-windowsize;
	    startj = k-windowsize;
	}

	while(i < len1 && k < len2)
	{
	    total = total - sub[(ajint)s1[i-windowsize]]
		[(ajint)s2[k-windowsize]];
	    total = total + sub[(ajint)s1[i]][(ajint)s2[k]];

	    if(abovethresh)
	    {
		if(total < thresh)
		{
		    abovethresh = 0;
		    /* draw the line */
		    dotmatcher_pushpoint(&list,(float)starti,(float)startj,
					 (float)i-1,(float)k-1,stretch);
		}
	    }
	    else if(total >= thresh)
	    {
		starti = i-windowsize;
		startj = k-windowsize;
		abovethresh= 1;
	    }
	    i++;
	    k++;
	}

	if(abovethresh)
	    /* draw the line */
	    dotmatcher_pushpoint(&list,(float)starti,(float)startj,
				 (float)i-1,(float)k-1,
				 stretch);
    }
    
    for(i=0; (ajint)i < (ajint)len1-windowsize;i++)
    {
	j = 0;
	total = 0;
	abovethresh =0;

	k = i;
	for(l=0;l<windowsize;l++)
	    total = total + sub[(ajint)s1[k++]][(ajint)s2[j++]];

	if(total >= thresh)
	{
	    abovethresh=1;
	    starti = k-windowsize;
	    startj = j-windowsize;
	}

	while(k < len1 && j < len2)
	{
	    total = total - sub[(ajint)s1[k-windowsize]]
		[(ajint)s2[j-windowsize]];
	    total = total + sub[(ajint)s1[k]][(ajint)s2[j]];

	    if(abovethresh)
	    {
		if(total < thresh)
		{
		    abovethresh = 0;
		    /* draw the line */
		    dotmatcher_pushpoint(&list,(float)starti,(float)startj,
					 (float)k-1,(float)j-1,stretch);
		}
	    }
	    else if(total >= thresh)
	    {
		starti = k-windowsize;
		startj = j-windowsize;
		abovethresh= 1;
	    }
	    j++;
	    k++;
	}

	if(abovethresh)
	    /* draw the line */
	    dotmatcher_pushpoint(&list,(float)starti,(float)startj,
				 (float)k-1,(float)j-1,
				 stretch);
    }
    
    if(boxit && !stretch)
    {
	ajGraphicsDrawposRect(0.0,0.0,flen1, flen2);

	i=0;
	while(acceptableticksx[i]*numbofticks < len1)
	    i++;

	if(i<=13)
	    tickgap = (float)acceptableticksx[i];
	else
	    tickgap = (float)acceptableticksx[10];
	ticklen   = xmargin*(float)0.1;
	onefifth  = xmargin*(float)0.2;

	if(len2/len1 > 10 )
	{
	    /* if a lot smaller then just label start and end */
	    ajGraphicsDrawposLine((float)0.0,(float)0.0,(float)0.0,(float)0.0-ticklen);
	    sprintf(ptr,"%d",b1-1);
	    ajGraphicsDrawposTextAtmid((float)0.0,(float)0.0-(onefifth),ptr);

	    ajGraphicsDrawposLine(flen1,(float)0.0,
			flen1,(float)0.0-ticklen);
	    sprintf(ptr,"%d",len1+b1-1);
	    ajGraphicsDrawposTextAtmid(flen1,(float)0.0-(onefifth),ptr);

	}
	else
	    for(k2=0.0;k2<len1;k2+=tickgap)
	    {
		ajGraphicsDrawposLine(k2,(float)0.0,k2,(float)0.0-ticklen);
		sprintf(ptr,"%d",(ajint)k2+b1-1);
		ajGraphicsDrawposTextAtmid(k2,(float)0.0-(onefifth),ptr);
	    }

	i = 0;
	while(acceptableticks[i]*numbofticks < len2)
	    i++;

	tickgap   = (float)acceptableticks[i];
	ticklen   = ymargin*(float)0.01;
	onefifth  = ymargin*(float)0.02;

	if(len1/len2 > 10 )
	{
	    /* if a lot smaller then just label start and end */
	    ajGraphicsDrawposLine((float)0.0,(float)0.0,(float)0.0-ticklen,(float)0.0);
	    sprintf(ptr,"%d",b2-1);
	    ajGraphicsDrawposTextAtend((float)0.0-(onefifth),(float)0.0,ptr);

	    ajGraphicsDrawposLine((float)0.0,flen2,(float)0.0-ticklen,
			flen2);
	    sprintf(ptr,"%d",len2+b2-1);
	    ajGraphicsDrawposTextAtend((float)0.0-(onefifth),flen2,ptr);
	}
	else
	    for(k2=0.0;k2<len2;k2+=tickgap)
	    {
		ajGraphicsDrawposLine((float)0.0,k2,(float)0.0-ticklen,k2);
		sprintf(ptr,"%d",(ajint)k2+b2-1);
		ajGraphicsDrawposTextAtend((float)0.0-(onefifth),k2,ptr);
	    }
    }
    
    
    if(!stretch)
	ajGraphicsClose();
    else			/* the xy graph for -stretch */
    {
	tit = ajStrNew();
	ajFmtPrintS(&tit,"%S",ajGraphGetTitleS(xygraph));


	gdata = ajGraphdataNewI(1);
	xa[0] = (float)b1;
	ya[0] = (float)b2;

	ajGraphSetTitleC(xygraph,ajStrGetPtr(tit));

	ajGraphSetXlabelC(xygraph,ajSeqGetNameC(seq));
	ajGraphSetYlabelC(xygraph,ajSeqGetNameC(seq2));

	ajGraphdataSetTypeC(gdata,"2D Plot Float");
	ajGraphdataSetTitleS(gdata,subt);
	ajGraphdataSetMinmax(gdata,(float)b1,(float)e1,(float)b2,
			       (float)e2);
	ajGraphdataSetTruescale(gdata,(float)b1,(float)e1,(float)b2,
			       (float)e2);
	ajGraphxySetXstartF(xygraph,(float)b1);
	ajGraphxySetXendF(xygraph,(float)e1);
	ajGraphxySetYstartF(xygraph,(float)b2);
	ajGraphxySetYendF(xygraph,(float)e2);

	ajGraphxySetXrangeII(xygraph,b1,e1);
	ajGraphxySetYrangeII(xygraph,b2,e2);


	if(list)
	{
	    iter = ajListIterNewread(list);
	    while((ppt = ajListIterGet(iter)))
	    {
		x1 = ppt->x1+b1-1;
		y1 = ppt->y1+b2-1;
		x2 = ppt->x2+b1-1;
		y2 = ppt->y2+b2-1;
		ajGraphAddLine(xygraph,x1,y1,x2,y2,0);
		AJFREE(ppt);
	    }
	    ajListIterDel(&iter);
	}

	ajGraphdataAddXY(gdata,xa,ya);
	ajGraphDataReplace(xygraph,gdata);


	ajGraphxyDisplay(xygraph,ajFalse);
	ajGraphicsClose();

	ajStrDel(&tit);
    }
    
    
    
    ajListFree(&list);

    ajSeqDel(&seq);
    ajSeqDel(&seq2);
    ajGraphxyDel(&graph);
    ajGraphxyDel(&xygraph);
    ajMatrixDel(&matrix);
    ajTimeDel(&ajtime);
    
    /* deallocate memory */
    ajStrDel(&aa0str);
    ajStrDel(&aa1str);
    ajStrDel(&se1);
    ajStrDel(&se2);
    ajStrDel(&subt);

    AJFREE(strret);			/* created withing ajFmtString */
    
    embExit();

    return 0;
}
Beispiel #4
0
int main(int argc, char **argv)
{
    AjPGraphdata graphdata;
    ajint i;
    AjPGraph mult;
    AjBool overlap;

    embInit("testplot", argc, argv);

    mult    = ajAcdGetGraphxy("graph");
    ipoints = ajAcdGetInt("points");
    overlap = ajAcdGetBoolean("overlap");

    ajUser("Plotting sin, cos and  tan for %d degrees",ipoints);

    /* Create multiple graph store for a set of graphs */
    /* This is used for drawing several graphs in one window */

    /* create a new graph */
    graphdata = ajGraphdataNewI(ipoints);

    /* add graph to list in a multiple graph */
    ajGraphDataAdd(mult,graphdata);

    /* set overlap based on bool*/
    ajGraphxySetflagOverlay(mult, overlap);

    /* create the point values for this graph */
    for(i=0;i<ipoints; i++)
    {
	graphdata->x[i] = (float)i;
	graphdata->y[i] = sin(ajCvtDegToRad(i));
    }

    /* embGraphSetData(graphdata,&array[0][0]);*/
    ajGraphdataSetYlabelC(graphdata,"SINE(degrees)");
    ajGraphdataSetXlabelC(graphdata,"degrees");
    ajGraphdataSetTitleC(graphdata,"hello");
    ajGraphdataSetColour(graphdata,GREEN);

    if(!overlap)
    {
	ajGraphdataAddposRect(graphdata,70.0,0.55,80.0,0.45,GREEN,1);
	ajGraphdataAddposTextC(graphdata,82.0,0.5,GREEN,"Sine");
    }

    graphdata = ajGraphdataNewI(ipoints);

    ajGraphDataAdd(mult,graphdata);

    for(i=0;i<ipoints; i++)
    {
	graphdata->x[i] = (float)i;
	graphdata->y[i] = cos(ajCvtDegToRad((float)i));
    }

    ajGraphdataSetXlabelC(graphdata,"degrees");
    ajGraphdataSetYlabelC(graphdata,"COS(degrees)");
    ajGraphdataSetTitleC(graphdata,"hello");
    ajGraphdataSetColour(graphdata,RED);

    if(!overlap)
    {
	ajGraphdataAddposLine(graphdata,5.0,0.1,15.0,0.1,RED);
	ajGraphdataAddposTextC(graphdata,17.0,0.1,RED,"Cosine");
    }

    /* now set larger axis than needed */
    ajGraphdataSetMinmax(graphdata,0.0,(float)ipoints,-0.5,1.5);

    graphdata = ajGraphdataNewI(ipoints);
    ajGraphdataSetLinetype(graphdata, 3);
    ajGraphDataAdd(mult,graphdata);

    for(i=0;i<ipoints; i++)
    {
	graphdata->x[i] = (float)i;
	graphdata->y[i] = (tan(ajCvtDegToRad(i))*0.2);
    }

    ajGraphdataSetXlabelC(graphdata,"degrees");
    ajGraphdataSetYlabelC(graphdata,"TAN(degrees)");
    ajGraphdataSetTitleC(graphdata,"hello");
    ajGraphdataSetLinetype(graphdata, 2);
    ajGraphdataSetColour(graphdata,BLUE);

    if(!overlap)
    {
	ajGraphdataAddposRect(graphdata,5.0,9.0,15.0,8.5,BLUE,0);
	ajGraphdataAddposTextC(graphdata,17.0,8.75,BLUE,"Tangent");
    }

    ajGraphSetYlabelC(mult,"sin,cos,tan");
    ajGraphSetXlabelC(mult,"degrees");
    ajGraphSetTitleC(mult,"Trig functions");

    ajGraphxySetYstartF(mult,0.0);
    ajGraphxySetYendF(mult,2.0);

    if(overlap)
    {
	ajGraphAddRect(mult,5.0,9.0,15.0,8.5,BLUE,0);
	ajGraphAddRect(mult,5.0,8.0,15.0,7.5,GREEN,1);
	ajGraphAddLine(mult,5.0,6.75,15.0,6.75,RED);
	ajGraphAddTextC(mult,17.0,8.75,BLUE,"Tangent");
	ajGraphAddTextC(mult,17.0,7.75,GREEN,"Sine");
	ajGraphAddTextC(mult,17.0,6.75,RED,"Cosine");
    }

    ajGraphxyDisplay(mult,AJTRUE);

    ajGraphxyDel(&mult);

    embExit();

    return 0;
}