home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / examples / example12.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-27  |  1.1 KB  |  66 lines

  1. /* Demonstration program for PLPLOT: Bar chart example. */
  2.  
  3. #include "plplot.h"
  4. #include <stdio.h>
  5.  
  6. void plfbox(x0,y0)
  7. PLFLT x0,y0;
  8. {
  9.    PLFLT x[4], y[4];
  10.  
  11.    x[0] = x0;
  12.    y[0] = 0.;
  13.    x[1] = x0;
  14.    y[1] = y0;
  15.    x[2] = x0+1.;
  16.    y[2] = y0;
  17.    x[3] = x0+1.;
  18.    y[3] = 0.;
  19.    plfill(4,x,y);
  20.    plcol(1);
  21.    pllsty(1);
  22.    plline(4,x,y);
  23. }
  24.  
  25. main()
  26. {
  27.    int i;
  28.    char string[20];
  29.    PLFLT y0[10];
  30.  
  31.    /* Ask user to specify the output device */
  32.    plstar(1,1);
  33.  
  34.    pladv(0);
  35.    plvsta();
  36.    plwind(1980.,1990.,0.,35.);
  37.    plbox("bc",1.,0,"bcnv",10.,0);
  38.    plcol(2);
  39.    pllab("Year","Widget Sales (millions)","#frPLPLOT Example 12");
  40.  
  41.    y0[0] = 5;
  42.    y0[1] = 15;
  43.    y0[2] = 12;
  44.    y0[3] = 24;
  45.    y0[4] = 28;
  46.    y0[5] = 30;
  47.    y0[6] = 20;
  48.    y0[7] = 8;
  49.    y0[8] = 12;
  50.    y0[9] = 3;
  51.  
  52.    for(i=0; i<10; i++) {
  53.       plcol(i%4+1);
  54.       plpsty((i+3)%8+1);
  55.       pllsty(i%8+1);
  56.       plfbox((PLFLT)(1980+i),y0[i]);
  57.       sprintf(string,"%.0f",y0[i]);
  58.       plptex(1980+i+.5,y0[i]+1.,1.,0.,.5,string);
  59.       sprintf(string,"%d",1980+i);
  60.       plmtex("b",1.,(i+1)*.1-.05,.5,string);
  61.    }
  62.  
  63.    /* Don't forget to call PLEND to finish off! */
  64.    plend();
  65. }
  66.