Ejemplo n.º 1
0
/* >>>>>>>>>> EX14_1 <<<<<<<<<< */
void ex14_1 (void)
{ int n = 50, i, j;
  double   fpi = 3.14159 / 180., step, x, y;
  float  zlev;

  step = 360. / (n - 1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    yray[i] = (float) (i * step);
  }

  for (i = 0; i < n; i++)
  { for (j = 0; j < n; j++)
    { x = xray[i] * fpi;
      y = yray[j] * fpi;    
      zmat[i][j] = (float) (2 * sin (x) * sin (y));
    }
  }

  setpag ("da4p");
  disini ();
  complx ();
  pagera ();

  titlin ("Contour Plot", 1);
  titlin ("F(X,Y) = 2 * SIN(X) * SIN(Y)", 3);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  intax  ();
  axspos (450, 2670);
  graf   (0.f, 360.f, 0.f, 90.f, 0.f, 360.f, 0.f, 90.f);

  height (30);
  for (i = 0; i < 9; i++)
  { zlev = (float) (-2. + i * 0.5);
    setclr ((i + 1) * 25);
    if (i == 4)
      labels ("none", "contur"); 
    else
      labels ("float", "contur");

    contur  (xray, n, yray, n, (float *) zmat, zlev);
  }

  height (50);
  color  ("fore");
  title  ();
  disfin ();
}
Ejemplo n.º 2
0
int main ()
{ int n = 100, i, ic;
  double fpi = 3.1415926 / 180.0, step, x;
  float  xray[100], y1ray[100], y2ray[100];

  step = 360. / (n - 1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    x = xray[i] * fpi;
    y1ray[i] = (float) sin (x);
    y2ray[i] = (float) cos (x);
  }

  metafl ("cons");
  scrmod ("revers");
  disini ();
  pagera ();
  complx ();
  axspos (450, 1800);
  axslen (2200, 1200);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  labdig (-1, "x");
  ticks  (9, "x");
  ticks  (10, "y");

  titlin ("Demonstration of CURVE", 1);
  titlin ("SIN(X), COS(X)", 3);

  ic =   intrgb (0.95,0.95,0.95);
  axsbgd (ic);

  graf   (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 0.5);
  setrgb (0.7, 0.7, 0.7);
  grid   (1, 1);

  color  ("fore");
  height (50);
  title  ();

  color  ("red");
  curve  (xray, y1ray, n);
  color  ("green");
  curve  (xray, y2ray, n);
  disfin ();
  return 0;
}
Ejemplo n.º 3
0
int main ( int argc, char *argv[] )

/******************************************************************************/
/*
  Purpose:

    CIRCLE_INOUT uses DISLIN to draw points in and out of a circle.

  Licensing:

    This code is distributed under the GNU LGPL license.

  Modified:

    01 May 2011

  Author:

    John Burkardt

  Reference:

    Helmut Michels,
    The Data Plotting Software DISLIN - version 10.4,
    Shaker Media GmbH, January 2010,
    ISBN13: 978-3-86858-517-9.
*/
{
  int i;
  int j;
  int m;
  int n_circle = 100;
  int n_in;
  int n_out;
  int pat;
  float pi = 3.14159265;
  float r;
  float s;
  float t;
  float *x;
  float *xy_in;
  float *xy_out;
  float *y;

  printf ( "\n" );
  printf ( "CIRCLE_INOUT:\n" );
  printf ( "  C version\n" );
  printf ( "  Use DISLIN routines to make a scatterplot.\n" );
/*
  Read the data.
*/
  r4mat_header_read ( "circle_in.txt", &m, &n_in );

  xy_in = r4mat_data_read ( "circle_in.txt", m, n_in );

  r4mat_header_read ( "circle_out.txt", &m, &n_out );

  xy_out = r4mat_data_read ( "circle_out.txt", m, n_out );
/*
  Specify the format of the output file.
*/
  metafl ( "png" );
/*
  Indicate that new data overwrites old data.
*/
  filmod ( "delete" );
/*
  Specify the name of the output graphics file.
*/
  setfil ( "circle_inout.png" );
/*
  Choose the page size and orientation.
  'USA' is 2160 plot units wide and 2790 plot units high.
  'P' requests PROFILE rather than LANDSCAPE orientation.
*/
  setpag ( "usap" );
/*
  For PNG output, use reverse the default black background to white.
*/
  scrmod ( "reverse" );
/*
  Open DISLIN.
*/
  disini ( );
/*
  Plot a border around the page.
*/
  pagera ( );
/*
  Use the COMPLEX font.
*/
  complx ( );
/*
  Set the axis origin 230 plot units to the right, and 2560 plot units DOWN.
*/
  axspos ( 230, 2560 );
/*
  Define the X and Y sizes of the axis system in plot units.
*/
  axslen ( 1700, 1700 );
/*
  Label the X and Y axes.
*/
  name ( "<--- X --->", "X" );
  name ( "<--- Y --->", "Y" );
/*
  Relate the physical coordinates to the axes.
*/
  graf ( 0.0, 1.0, 0.0, 0.1, 0.0, 1.0, 0.0, 0.1 );
/*
  Define axis system titles.
*/
  titlin ( "Random points inside/outside the unit circle", 1 );
/*
  Draw the title.
*/
  title ( );
/*
  Add a grid, with one grid line for every tick mark in the X and Y axes.
*/
  grid ( 1, 1 );
/*
  Select the shading pattern.
*/
  pat = 16;
  shdpat ( pat );
/*
  Set the color to blue.
*/
  color ( "blue" );
/*
  At every data point, draw a circle of radius 0.01.
*/
  for ( i = 0; i < n_in; i++ )
  {
    rlcirc ( xy_in[0+i*2], xy_in[1+i*2], 0.01 );
  }
/*
  Set the color to red.
*/
  color ( "red" );
/*
  At every data point, draw a circle of radius 0.01.
*/
  for ( i = 0; i < n_out; i++ )
  {
    rlcirc ( xy_out[0+i*2], xy_out[1+i*2], 0.01 );
  }
/*
  Draw a red circle.
*/
  x = ( float * ) malloc ( n_circle * sizeof ( float ) );
  y = ( float * ) malloc ( n_circle * sizeof ( float ) );

  for ( i = 0; i < n_circle; i++ )
  {
    t = pi * ( float ) ( i ) / ( float ) ( n_circle - 1 );
    x[i] = cos ( t );
    y[i] = sin ( t );
  }
  thkcrv ( 10 );
  curve ( x, y, n_circle );
/*
  End this plot.
*/
  endgrf ( );
/*
  Free memory.
*/
  free ( x );
  free ( xy_in );
  free ( xy_out );
  free ( y );
/*
  Close DISLIN.
*/
  disfin ( );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "CIRCLE_INOUT:\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}
Ejemplo n.º 4
0
int main ( int argc, char *argv[] )

/******************************************************************************/
/*
  Purpose:

    MAIN demonstrates the use of bar graphs.

  Modified:
 
    09 April 2011

  Reference:

    Helmut Michels,
    The Data Plotting Software DISLIN - version 10.4,
    Shaker Media GmbH, January 2010,
    ISBN13: 978-3-86858-517-9.
*/
{
  static char cbuf[25];
  static char *ctit = "Bar Graphs (BARS)";
  int i;
  int nya = 2700;
  static float x[9]  = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 };
  static float y[9]  = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
  static float y1[9] = { 1.0, 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1 };
  static float y2[9] = { 2.0, 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8 };
  static float y3[9] = { 4.0, 3.5, 4.5, 3.7, 4.0, 2.9, 3.0, 3.2, 2.6 };

  printf ( "\n" );
  printf ( "DISLIN_EX05:\n" );
  printf ( "  C version:\n" );
  printf ( "  Demonstrate the display of data in bar graphs.\n" );
/*
  Specify the format of the output file.
*/
  metafl ( "png" );
/*
  Specify that if a file already exists of the given name,
  the new data should overwrite the old.
*/
  filmod ( "delete" );
/*
  Specify the name of the output graphics file.
*/
  setfil ( "dislin_ex05.png" );
/*
  Choose the page size and orientation.
*/
  setpag ( "usap" );
/*
  For PNG output, reverse the default black background to white.
*/
  scrmod ( "reverse" );
/*
  Open DISLIN.
*/
  disini ( );
/*
  Plot a border around the page.
*/
  pagera ( );
/*
  Use the COMPLEX font.
*/
  complx ( );
  ticks ( 1, "x" );
  intax ( );
  axslen ( 1600, 700 );
  titlin ( ctit, 3 );

  legini ( cbuf, 3, 8 );
  leglin ( cbuf, "FIRST", 1 );
  leglin ( cbuf, "SECOND", 2 );
  leglin ( cbuf, "THIRD", 3 );
  legtit ( " " );
  shdpat ( 5L );

  for ( i = 1; i <= 3; i++ )
  {
     if ( 1 < i )
     {
       labels ( "none", "x" );
     }
    axspos ( 300, nya-(i-1)*800 );

    graf ( 0.0, 10.0, 0.0, 1.0, 0.0, 5.0, 0.0, 1.0 );

    if ( i == 1 )
    {
      bargrp ( 3, 0.15 );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "green" );
      bars ( x, y, y2, 9 );
      color ( "blue" );
      bars ( x, y, y3, 9 );
      color ( "fore" );
      reset ( "bargrp" );
    }
    else if ( i == 2 )
    {
      height ( 30 );
      labels ( "delta", "bars" );
      labpos ( "center", "bars" );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "green" );
      bars ( x, y1, y2, 9 );
      color ( "blue" );
      bars ( x, y2, y3, 9 );
      color ( "fore" );
      reset ( "height" ); 
    }
    else if ( i == 3 )
    {
      labels ( "second", "bars" );
      labpos ( "outside", "bars" );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "fore" );
    }

    if ( i < 3 )
    {
      legend ( cbuf, 7 );
    }
    else
    {
      height ( 50 );
      title ( );
    }

    endgrf ( );
  }
/*
  Close DISLIN.
*/
  disfin ( );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "DISLIN_EX05:\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}