//-------------------------------------------------------------------------- //Actually draw the map lines points and text. //-------------------------------------------------------------------------- void drawmapdata( void ( *mapform )( PLINT, PLFLT *, PLFLT * ), int shapetype, PLINT n, PLFLT *x, PLFLT *y, PLFLT dx, PLFLT dy, PLFLT just, const char *text ) { PLINT i; //do the transform if needed if ( mapform != NULL ) ( *mapform )( n, x, y ); if ( shapetype == SHPT_ARC ) plline( n, x, y ); else if ( shapetype == SHPT_POINT ) for ( i = 0; i < n; ++i ) plptex( x[i], y[i], dx, dy, just, text ); else if ( shapetype == SHPT_POLYGON ) plfill( n, x, y ); #ifdef HAVE_SHAPELIB else if ( shapetype == SHPT_ARCZ || shapetype == SHPT_ARCM ) plline( n, x, y ); else if ( shapetype == SHPT_POLYGON || shapetype == SHPT_POLYGONZ || shapetype == SHPT_POLYGONM ) plfill( n, x, y ); else if ( shapetype == SHPT_POINT || shapetype == SHPT_POINTM || shapetype == SHPT_POINTZ ) for ( i = 0; i < n; ++i ) plptex( x[i], y[i], dx, dy, just, text ); #endif //HAVE_SHAPELIB }
static void plstrip_gen( PLStrip *strip ) { int i; PLFLT x[]={0.,1.,1.,0.}, y[]={0.,0.,1.,1.}; /* Set up window */ plvpor(0,1,0,1); plwind(0,1,0,1); plcol(0);plpsty(0); plfill(4, &x[0], &y[0]); plvsta(); /* Draw box and same window dimensions */ strip->wxmin=strip->xmin; strip->wxmax=strip->xmax; strip->wymin=strip->ymin; strip->wymax=strip->ymax; /* FIXME - can exist some redundancy here */ plwind(strip->xmin, strip->xmax, strip->ymin, strip->ymax); pllsty(1); plcol(strip->colbox); plbox(strip->xspec, 0.0, 0, strip->yspec, 0.0, 0); plcol(strip->collab); pllab(strip->labx, strip->laby, strip->labtop); for (i=0; i<PEN; i++) { if (strip->npts[i] > 0) { plcol(strip->colline[i]);pllsty(strip->styline[i]); plline(strip->npts[i], strip->x[i], strip->y[i]); } } plstrip_legend(strip,0); }
int main( int argc, char *argv[] ) { int i, j; plparseopts( &argc, argv, PL_PARSE_FULL ); plinit(); pladv( 0 ); plvpor( 0.0, 1.0, 0.0, 1.0 ); plwind( 0.0, 1.0, 0.0, 1.0 ); plcol0( 0 ); plbox( "", 1.0, 0, "", 1.0, 0 ); plscmap0n( 7 ); plscmap0( red, green, blue, 7 ); plschr( 0, 4.0 ); plfont( 1 ); for ( i = 0; i < 4; i++ ) { plcol0( i + 1 ); plfill( 4, px, py ); for ( j = 0; j < 4; j++ ) py [j] += 1.0 / 4.0; } plcol0( 0 ); for ( i = 0; i < 12; i++ ) plptex( sx [i], sy [i], 1.0, 0.0, 0.5, peace [i] ); plend(); exit( 0 ); }
void draw_page( PLINT mode, const char *title ) { PLFLT xs[3], ys[3]; PLFLT over_x, over_y, over_r; // A triangle for the background xs[0] = 0.0; xs[1] = 1.0; xs[2] = 0.0; ys[0] = 0.0; ys[1] = 1.0; ys[2] = 1.0; // A circle for the foreground over_x = 0.5; over_y = 0.5; over_r = 0.4; plcol0( 1 ); // Setup a plot window plenv( 0.0, 1.0, 0.0, 1.0, 1, 0 ); // Show which mode we're using pllab( "", "", title ); // Draw a background triangle using the default drawing mode plcol0( 2 ); plsdrawmode( PL_DRAWMODE_DEFAULT ); plfill( 3, xs, ys ); // Draw a circle in the given drawing mode plcol0( 3 ); plsdrawmode( mode ); plarc( over_x, over_y, over_r, over_r, 0.0, 360.0, 0.0, 1 ); }
int main( int argc, const char *argv[] ) { int i, j, k; int npts = 0; PLFLT xextreme[10][2]; PLFLT yextreme[10][2]; PLFLT x0[10]; PLFLT y0[10]; // Parse and process command line arguments (void) plparseopts( &argc, argv, PL_PARSE_FULL ); // Initialize plplot plssub( 3, 3 ); plinit(); xextreme[0][0] = -120.0; xextreme[0][1] = 120.0; yextreme[0][0] = -120.0; yextreme[0][1] = 120.0; xextreme[1][0] = -120.0; xextreme[1][1] = 120.0; yextreme[1][0] = 20.0; yextreme[1][1] = 120.0; xextreme[2][0] = -120.0; xextreme[2][1] = 120.0; yextreme[2][0] = -20.0; yextreme[2][1] = 120.0; xextreme[3][0] = -80.0; xextreme[3][1] = 80.0; yextreme[3][0] = -20.0; yextreme[3][1] = 120.0; xextreme[4][0] = -220.0; xextreme[4][1] = -120.0; yextreme[4][0] = -120.0; yextreme[4][1] = 120.0; xextreme[5][0] = -20.0; xextreme[5][1] = 20.0; yextreme[5][0] = -120.0; yextreme[5][1] = 120.0; xextreme[6][0] = -20.0; xextreme[6][1] = 20.0; yextreme[6][0] = -20.0; yextreme[6][1] = 20.0; xextreme[7][0] = -80.0; xextreme[7][1] = 80.0; yextreme[7][0] = -80.0; yextreme[7][1] = 80.0; xextreme[8][0] = 20.0; xextreme[8][1] = 120.0; yextreme[8][0] = -120.0; yextreme[8][1] = 120.0; for ( k = 0; k < 2; k++ ) { for ( j = 0; j < 4; j++ ) { if ( j == 0 ) { // Polygon 1: a diamond x0[0] = 0; y0[0] = -100; x0[1] = -100; y0[1] = 0; x0[2] = 0; y0[2] = 100; x0[3] = 100; y0[3] = 0; npts = 4; } if ( j == 1 ) { // Polygon 1: a diamond - reverse direction x0[3] = 0; y0[3] = -100; x0[2] = -100; y0[2] = 0; x0[1] = 0; y0[1] = 100; x0[0] = 100; y0[0] = 0; npts = 4; } if ( j == 2 ) { // Polygon 2: a square with punctures x0[0] = -100; y0[0] = -100; x0[1] = -100; y0[1] = -80; x0[2] = 80; y0[2] = 0; x0[3] = -100; y0[3] = 80; x0[4] = -100; y0[4] = 100; x0[5] = -80; y0[5] = 100; x0[6] = 0; y0[6] = 80; x0[7] = 80; y0[7] = 100; x0[8] = 100; y0[8] = 100; x0[9] = 100; y0[9] = -100; npts = 10; } if ( j == 3 ) { // Polygon 2: a square with punctures - reversed direction x0[9] = -100; y0[9] = -100; x0[8] = -100; y0[8] = -80; x0[7] = 80; y0[7] = 0; x0[6] = -100; y0[6] = 80; x0[5] = -100; y0[5] = 100; x0[4] = -80; y0[4] = 100; x0[3] = 0; y0[3] = 80; x0[2] = 80; y0[2] = 100; x0[1] = 100; y0[1] = 100; x0[0] = 100; y0[0] = -100; npts = 10; } for ( i = 0; i < 9; i++ ) { pladv( 0 ); plvsta(); plwind( xextreme[i][0], xextreme[i][1], yextreme[i][0], yextreme[i][1] ); plcol0( 2 ); plbox( "bc", 1.0, 0, "bcnv", 10.0, 0 ); plcol0( 1 ); plpsty( 0 ); if ( k == 0 ) plfill( npts, x0, y0 ); else plgradient( npts, x0, y0, 45. ); plcol0( 2 ); pllsty( 1 ); plline( npts, x0, y0 ); } } } // Don't forget to call plend() to finish off! plend(); exit( 0 ); }
int main( int argc, const char *argv[] ) { int i, j, dthet, theta0, theta1, theta; PLFLT just, dx, dy; static PLFLT x[500], y[500], per[5]; per[0] = 10.; per[1] = 32.; per[2] = 12.; per[3] = 30.; per[4] = 16.; // Parse and process command line arguments (void) plparseopts( &argc, argv, PL_PARSE_FULL ); // Initialize plplot plinit(); pladv( 0 ); // Ensure window has aspect ratio of one so circle is // plotted as a circle. plvasp( 1.0 ); plwind( 0., 10., 0., 10. ); // plenv(0., 10., 0., 10., 1, -2); plcol0( 2 ); // n.b. all theta quantities scaled by 2*M_PI/500 to be integers to avoid // floating point logic problems. theta0 = 0; dthet = 1; for ( i = 0; i <= 4; i++ ) { j = 0; x[j] = 5.; y[j++] = 5.; // n.b. the theta quantities multiplied by 2*M_PI/500 afterward so // in fact per is interpreted as a percentage. theta1 = (int) ( theta0 + 5 * per[i] ); if ( i == 4 ) theta1 = 500; for ( theta = theta0; theta <= theta1; theta += dthet ) { x[j] = 5 + 3 * cos( ( 2. * M_PI / 500. ) * theta ); y[j++] = 5 + 3 * sin( ( 2. * M_PI / 500. ) * theta ); } plcol0( i + 1 ); plpsty( ( i + 3 ) % 8 + 1 ); plfill( j, x, y ); plcol0( 1 ); plline( j, x, y ); just = ( 2. * M_PI / 500. ) * ( theta0 + theta1 ) / 2.; dx = .25 * cos( just ); dy = .25 * sin( just ); if ( ( theta0 + theta1 ) < 250 || ( theta0 + theta1 ) > 750 ) just = 0.; else just = 1.; plptex( ( x[j / 2] + dx ), ( y[j / 2] + dy ), 1.0, 0.0, just, text[i] ); theta0 = theta - dthet; } plfont( 2 ); plschr( 0., 1.3 ); plptex( 5.0, 9.0, 1.0, 0.0, 0.5, "Percentage of Sales" ); // Don't forget to call PLEND to finish off! plend(); exit( 0 ); }