/* >>>>>>>>>> EX13_3 <<<<<<<<<< */ void ex13_3 (void) { int nl, nx, i; static int nxa[4] = {200, 1150, 200, 1150}, nya[4] = {1600, 1600, 2700, 2700}; static float xpol[4] = {0.f, 0.f, 0.f, 0.f}, ypol[4] = {0.f, 45.f, 90.f, -45.f}; static char *ctit = "Azimuthal Lambert Projections"; setpag ("da4p"); disini (); hwfont (); pagera (); height (50); nl = nlmess (ctit); nx = (2250 - nl) / 2; messag (ctit, nx, 300); axslen (900, 900); projct ("lambert"); for(i = 0; i < 4; i++) { axspos (nxa[i], nya[i]); mappol (xpol[i], ypol[i]); grafmp (-180.f, 180.f, -180.f, 30.f, -90.f, 90.f, -90.f, 30.f); color ("green"); world (); color ("fore"); gridmp (1, 1); endgrf (); } disfin (); }
/* >>>>>>>>>> EX13_2 <<<<<<<<<< */ void ex13_2 (void) { int nya, i; static char *cproj[3] = {"Sanson", "Winkel", "Hammer"}; char ctit[61]; setpag ("da4p"); disini (); hwfont (); pagera (); height (40); axslen (1600, 750); nya = 3850; for (i = 0; i < 3; i++) { nya = nya - 950; axspos (250, nya); projct (cproj[i]); noclip (); grafmp (-180.f, 180.f, -180.f, 30.f, -90.f, 90.f, -90.f, 15.f); sprintf (ctit, "%s%s", "Elliptical Projection of ", cproj[i]); titlin (ctit, 4); title (); color ("green"); world (); color ("fore"); gridmp (1, 1); endgrf (); } disfin (); }
/* >>>>>>>>>> EXA_2 <<<<<<<<<< */ void exa_2 (void) { int n = 300, m = 10, i; double f = 3.1415926 / 180., step, a; float x2[10], y2[10]; step = 360. / (n - 1); for (i = 0; i < n; i++) { a = i * step * f; yray[i] = (float) a; xray[i] = (float) sin (5 * a); } for (i = 0; i < m; i++) { x2[i] = i + 1; y2[i] = i + 1; } setpag ("da4p"); disini (); pagera (); hwfont (); axspos (450,1800); titlin ("Polar Plots", 2); ticks (3, "Y"); axends ("NOENDS", "X"); labdig (-1, "Y"); axslen (1000, 1000); axsorg (1050, 900); grafp (1.f ,0.f, 0.2f, 0.f, 30.f); curve (xray, yray, n); htitle (50); title (); endgrf (); labdig (-1, "X"); axsorg (1050, 2250); labtyp ("VERT", "Y"); grafp (10.f, 0.f, 2.f, 0.f, 30.f); barwth (-5.f); polcrv ("FBARS"); curve (x2, y2, m); disfin (); }
/* >>>>>>>>>> EXA_5 <<<<<<<<<< */ void exa_5 (void) { int nya = 2700, i, nx, ny; static float x[] = { 0.0f, 1.0f, 3.0f, 4.5f, 6.0f, 8.0f, 9.0f, 11.0f, 12.0f, 12.5f, 13.0f, 15.0f, 16.0f, 17.0f, 19.0f, 20.0f}, y[] = { 2.0f, 4.0f, 4.5f, 3.0f, 1.0f, 7.0f, 2.0f, 3.0f, 5.0f, 2.0f, 2.5f, 2.0f, 4.0f, 6.0f, 5.5f, 4.0f}; static char *cpol[6] = {"SPLINE", "STEM", "BARS", "STAIRS", "STEP", "LINEAR"}, *ctit = "Interpolation Methods"; setpag ("da4p"); disini (); hwfont (); pagera (); incmrk (1); hsymbl (25); titlin (ctit, 1); axslen (1500, 350); setgrf ("line", "line", "line", "line"); for (i = 0; i < 6; i++) { axspos (350, nya - i * 350); polcrv (cpol[i]); marker (0); graf (0.f, 20.f, 0.f, 5.f, 0.f, 10.f, 0.f, 5.f); nx = nxposn (1.f); ny = nyposn (8.f); color ("yellow"); messag (cpol[i], nx, ny); curve (x, y, 16); color ("fore"); if (i == 5) { height (50); title (); } endgrf (); } disfin (); }
/* >>>>>>>>>> EXA_4 <<<<<<<<<< */ void exa_4 (void) { int nya, i; static char ctit[] = "Logarithmic Scaling", cstr[60], *clab[3] = {"LOG", "FLOAT", "ELOG"}; setpag ("da4p"); disini (); pagera (); hwfont (); axslen (1400, 500); name ("X-axis", "x"); name ("Y-axis", "y"); axsscl ("log", "xy"); titlin (ctit, 2); for (i = 1; i <= 3; i++) { nya = 2650 - (i - 1) * 800; labdig (-1, "xy"); if (i == 2) { labdig (1, "y"); name (" ", "x"); } axspos (500, nya); color ("yellow"); strcpy (cstr, "Labels: "); strcat (cstr, clab[i-1]); messag (cstr,600,nya-400); color ("fore"); labels (clab[i-1],"xy"); graf (0.f, 3.f, 0.f, 1.f, -1.f, 2.f, -1.f, 1.f); if (i == 3) { height (50); title (); } endgrf (); } disfin (); }
/* >>>>>>>>>> EX10_2 <<<<<<<<<< */ void ex10_2 (void) { int nya = 2800, i; static char *ctit = "Pie Charts (PIEGRF)", cbuf[41]; static float xdray[5] = {1.f, 2.5f, 2.f, 2.7f, 1.8f}; setpag ("da4p"); disini (); pagera (); hwfont (); axslen (1600, 1000); titlin (ctit, 2); chnpie ("both"); legini (cbuf, 5, 8); leglin (cbuf, "FIRST", 1); leglin (cbuf, "SECOND", 2); leglin (cbuf, "THIRD", 3); leglin (cbuf, "FOURTH", 4); leglin (cbuf, "FIFTH", 5); patcyc (1, 7L); patcyc (2, 4L); patcyc (3, 13L); patcyc (4, 3L); patcyc (5, 5L); for (i = 0; i < 2; i++) { axspos (250,nya - i * 1200); if (i == 1) { labels ("data", "pie"); labpos ("external", "pie"); } piegrf (cbuf, 1, xdray, 5); if (i == 1) { height (50); title (); } endgrf (); } disfin (); }
/* >>>>>>>>>> EX10_3 <<<<<<<<<< */ void ex10_3 (void) { char cbuf[80]; float x[5] = {2., 4., 6., 8., 10.}, y1[5] = {0., 0., 0., 0., 0.}, y2[5] = {3.2, 1.5, 2.0, 1.0, 3.0}; int ic1ray[5] = {50, 150, 100, 200, 175}, ic2ray[5] = {50, 150, 100, 200, 175}; setpag ("da4p"); disini (); pagera (); hwfont (); titlin ("3-D Bar Graph / 3-D Pie Chart", 2); htitle (40); shdpat (16L); axslen (1500, 1000); axspos (300, 1400); barwth (0.5); bartyp ("3dvert"); labels ("second", "bars"); labpos ("outside", "bars"); graf (0., 12., 0., 2., 0., 5., 0., 1.); title (); color ("red"); bars (x, y1, y2, 5); endgrf (); shdpat (16L); labels ("data", "pie"); chnpie ("none"); pieclr (ic1ray, ic2ray, 5); pietyp ("3d"); axspos (300, 2700); piegrf (cbuf, 0, y2, 5); disfin (); }
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; }
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; }
int main ( int argc, char *argv[] ) /******************************************************************************/ /* Purpose: ORBITAL uses DISLIN to display a contour plot of Z(X,Y) data. Licensing: This code is distributed under the GNU LGPL license. Modified: 20 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 k; int level; int level_num; float level_value; int m; int n; int nn; float *x; float xmax; float xmin; float *xyz; float *y; float ymax; float ymin; float *z; float zmax; float zmin; printf ( "\n" ); printf ( "ORBITAL:\n" ); printf ( " C version:\n" ); printf ( " Use DISLIN to make a contour plot of Z(X,Y) data.\n" ); /* Read the data. */ r4mat_header_read ( "orbital.txt", &m, &nn ); xyz = r4mat_data_read ( "orbital.txt", m, nn ); /* Split the data. The contouring routine expects that data is along fixed X and Y coordinates, and so the X and Y data is to be given as vectors, not arrays. */ n = 101; x = ( float * ) malloc ( n * sizeof ( float ) ); y = ( float * ) malloc ( n * sizeof ( float ) ); z = ( float * ) malloc ( n * n * sizeof ( float ) ); k = 0; for ( i = 0; i < n; i++ ) { x[i] = xyz[0+k*3]; k = k + 1; } xmin = r4vec_min ( n, x ); xmax = r4vec_max ( n, x ); k = 0; for ( i = 0; i < n; i++ ) { y[i] = xyz[1+k*3]; k = k + n; } ymin = r4vec_min ( n, y ); ymax = r4vec_max ( n, y ); /* Z is a table. The first dimension should contain values for constant Y. */ k = 0; for ( i = 0; i < n; i++ ) { for ( j = 0; j < n; j++ ) { z[i+j*n] = xyz[2+k*3]; k = k + 1; } } zmax = r4mat_max ( n, n, z ); zmin = r4mat_min ( n, n, z ); /* 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 ( "orbital.png" ); /* Choose the page size and orientation. 'USA' is 2160 plot units wide and 2790 plot units high. 'P' requests PORTRAIT 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 SIMPLX font. */ simplx ( ); /* Set the axis origin in plot units to the right, and plot units DOWN. */ axspos ( 230, 2500 ); /* Define the X and Y sizes of the axis system in plot units. */ axslen ( 1700, 1700 ); /* Label the X and Y axes. */ name ( "X axis", "X" ); name ( "Y axis", "Y" ); /* Relate the physical coordinates to the axes, and specify tick marks. */ graf ( xmin, xmax, xmin, 1.0, ymin, ymax, ymin, 1.0 ); /* BEGIN LEVEL 2 COMMANDS. */ /* Define the title. */ titlin ( "Orbital contour plot", 1 ); title ( ); /* Set color to "blue". */ color ( "blue" ); /* Draw the contour plot. */ level_num = 10; for ( level = 1; level <= level_num; level++ ) { level_value = ( ( float ) ( level_num + 1 - level ) * zmin + ( float ) ( level ) * zmax ) / ( float ) ( level_num + 1 ); contur ( x, n, y, n, z, level_value ); } /* End this graph. */ endgrf ( ); /* RETURN FROM LEVEL 2 TO LEVEL 1. */ /* Close DISLIN. */ disfin ( ); /* Free memory. */ free ( x ); free ( xyz ); free ( y ); free ( z ); /* Terminate. */ printf ( "\n" ); printf ( "ORBITAL:\n" ); printf ( " Normal end of execution.\n" ); return 0; }
/* >>>>>>>>>> EX10_1 <<<<<<<<<< */ void ex10_1 (void) { int nya = 2700, i; static char *ctit = "Bar Graphs (BARS)", cbuf[25]; static float x[9] = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f}, y[9] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}, y1[9] = {1.f, 1.5f, 2.5f, 1.3f, 2.0f, 1.2f, 0.7f, 1.4f, 1.1f}, y2[9] = {2.f, 2.7f, 3.5f, 2.1f, 3.2f, 1.9f, 2.0f, 2.3f, 1.8f}, y3[9] = {4.f, 3.5f, 4.5f, 3.7f, 4.0f, 2.9f, 3.0f, 3.2f, 2.6f}; setpag ("da4p"); disini (); pagera (); hwfont (); 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 (i > 1) labels ("none", "x"); axspos (300, nya - (i - 1) * 800); graf (0.f, 10.f, 0.f, 1.f, 0.f, 5.f, 0.f, 1.f); if (i == 1) { bargrp (3, 0.15f); 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); if (i == 3) { height (50); title (); } endgrf (); } disfin (); }