Skip to ContentSkip to Navigation
Society/business Center for Information Technology Research and Innovation Support Virtual Reality and Visualisation

Scientific graph

								
/* this program plots a curve and a set of experimatel data with errorbars
Special feautures:
- automatic scaling
- second graph with logarithmic Y-as
  */

#include <stdio.h>
#include <math.h>
#include "komplot.h"

int main()
{
 float x[14], y[14];
 float xh;
 int i;
 float xe[] = {-0.4, 0.7,-0.1, 0.5, 1.2, 0.3, 1.0, 2.0};
 float ye[] = { 0.8, 1.8, 1.0, 1.6, 3.5, 1.4, 2.5, 7.3};
 float fe[] = {0.1, 0.2, 0.1, 0.2, 0.2, 0.1, 0.8, 0.3};

 frame_style("scientific");
/* define font = Helvetica (default Times-Roman)*/
 ps_define_font("A", "Helvetica");

/* automatic scaling alog y axis */
 frame(12, -0.5, 2.5, 10, 0, 0, "X", "Y", "Scientific graph");
 xh = -0.6;
 for (i=1 ; i < 15 ; i++)
  {
    xh = xh +0.2;
    x[i-1] = xh;
    y[i-1] = exp(xh);
  }
 curve("y = exp(x)", 14, x, y);
 markers("Experimental data", 8, xe, ye, 17); 
 v_errorbars("with error bars ", 8, xe, ye, fe);

/* same graph with logarithmic Y-axis (ysize = -10) */
 frame(12, -0.5, 2.5, -10, 0, 0, "X", "Y", "Scientific graph");
 curve("y = exp(x)", 14, x, y);
 markers("Experimental data", 8, xe, ye, 17); 
 v_errorbars(" ", 8, xe, ye, fe);

 printf (" >>>>>> This program generated KOMPLOT.TMP\n");
 printf (" >>>>>> KOMPLOT.TMP is inputfile for komplot\n");

/*
 komplot(40,"sg.ps");
 system("xv sg.ps"); 
*/
 return 0;

}

 

							
Last modified:02 October 2015 10.22 p.m.