ftp.nice.ch/pub/next/unix/developer/plplot.3.0.s.tar.gz#/plplot/examples/example12.c

This is example12.c in view mode; [Download] [Up]

/* Demonstration program for PLPLOT: Bar chart example. */
#include <stdio.h>

void plfbox(x0,y0)
double x0,y0;
{
   FLOAT x[4], y[4];

   x[0] = x0;
   y[0] = 0.;
   x[1] = x0;
   y[1] = y0;
   x[2] = x0+1.;
   y[2] = y0;
   x[3] = x0+1.;
   y[3] = 0.;
   plfill(4,x,y);
   plcol(1);
   pllsty(1);
   plline(4,x,y);
}

main()
{
   int i;
   char string[20];
   double y0[10];

   /* Ask user to specify the output device */
   plstar(1,1);

   pladv(0);
   plvsta();
   plwind(1980.,1990.,0.,35.);
   plbox("bc",1.,0,"bcnv",10.,0);
   plcol(2);
   pllab("Year","Widget Sales (millions)","#frPLPLOT Example 12");

   y0[0] = 5;
   y0[1] = 15;
   y0[2] = 12;
   y0[3] = 24;
   y0[4] = 28;
   y0[5] = 30;
   y0[6] = 20;
   y0[7] = 8;
   y0[8] = 12;
   y0[9] = 3;

   for(i=0; i<10; i++) {
      plcol(i%4+1);
      plpsty((i+3)%8+1);
      pllsty(i%8+1);
      plfbox((1980.+i),y0[i]);
      sprintf(string,"%.0f",y0[i]);
      plptex((1980.+i+.5),(y0[i]+1.),1.,0.,.5,string);
      sprintf(string,"%d",1980+i);
      plmtex("b",1.,((i+1)*.1-.05),.5,string);
   }

   /* Don't forget to call PLEND to finish off! */
   plend();
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.