static void plot3( void ) { static PLFLT xx[2][5] = { { -1.0, 1.0, 1.0, -1.0, -1.0 }, { -1.0, 1.0, 1.0, -1.0, -1.0 } }; static PLFLT yy[2][5] = { { 1.0, 1.0, 0.0, 0.0, 1.0 }, { -1.0, -1.0, 0.0, 0.0, -1.0 } }; static PLFLT zz[2][5] = { { 0.0, 0.0, 1.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0, 1.0, 0.0 } }; pladv( 0 ); plvpor( 0.1, 0.9, 0.1, 0.9 ); plwind( -1.0, 1.0, -1.0, 1.0 ); plw3d( 1., 1., 1., -1.0, 1.0, -1.0, 1.0, 0.0, 1.5, 30, -40 ); /* Plot using identity transform */ plcol0( 1 ); plbox3( "bntu", "X", 0.0, 0, "bntu", "Y", 0.0, 0, "bcdfntu", "Z", 0.5, 0 ); plcol0( 2 ); pllab( "", "", "3-d polygon filling" ); plcol0( 3 ); plpsty( 1 ); plline3( 5, xx[0], yy[0], zz[0] ); plfill3( 4, xx[0], yy[0], zz[0] ); plpsty( 2 ); plline3( 5, xx[1], yy[1], zz[1] ); plfill3( 4, xx[1], yy[1], zz[1] ); }
BarChart2::BarChart2(MyPlotwindow *m_plot, wxString filename, PlotParam b2style) { pls = m_plot->GetStream(); wxFileInputStream fin( filename ); wxTextInputStream text( fin ); double x[36]; float a[36],b[36]; for(int i=0;i<36;i++) { x[i]=i+1.0; text>>b[i]>>a[i]; } pls->adv( 0 ); pls->vsta(); pls->wind( 0, 37, -b2style.ymax*0.001, b2style.ymax*0.001 ); plcol0( 15 ); pls->box( "abcnt", 5.0, 0, "bcntv", 0, 0 ); pls->lab( "quad index", "#gDk#d1#ul (1/m)", "" ); plcol0( 0 ); plcol1( 1 ); plpsty( 0 ); for (int i = 0; i < 36; i++ ) { plfbox_solid( x[i]-0.3, b[i], 0.25); } plcol1( 0 ); plpsty( 0 ); //pls->lsty( 1 ); for (int i = 0; i < 36; i++ ) { plfbox_solid( x[i]+0.05, a[i] , 0.25); } //legend pls->vpor(0.15, 0.28, 0.75, 0.85); pls->wind( 0, 1, 0, 1 ); plcol0( 5 ); pls->box( "bc", 0, 0, "bc", 0, 0 ); pls->ptex( 0.4, 0.7, 0.0, 0.0, 0, "before" ); pls->ptex( 0.4, 0.2, 0.0, 0.0, 0, "after " ); plcol1( 1 ); PLFLT x1[]={0.1,0.1,0.35,0.35}; PLFLT y1[]={0.7,0.8,0.8 ,0.7}; pls->fill( 4, x1, y1 ); PLFLT x2[]={0.1,0.1,0.35 ,0.35 }; PLFLT y2[]={0.2,0.3,0.3 ,0.2}; plcol1( 0 ); pls->fill( 4, x2, y2 ); m_plot->RenewPlot(); }
static void plot1( void ) { PLFLT shade_min, shade_max, sh_color; PLINT sh_cmap = 0, sh_width; PLINT min_color = 0, min_width = 0, max_color = 0, max_width = 0; pladv( 0 ); plvpor( 0.1, 0.9, 0.1, 0.9 ); plwind( -1.0, 1.0, -1.0, 1.0 ); /* Plot using identity transform */ shade_min = zmin + ( zmax - zmin ) * 0.4; shade_max = zmin + ( zmax - zmin ) * 0.6; sh_color = 7; sh_width = 2; min_color = 9; max_color = 2; min_width = 2; max_width = 2; plpsty( 8 ); plshade1( &z[0][0], XPTS, YPTS, NULL, -1., 1., -1., 1., shade_min, shade_max, sh_cmap, sh_color, sh_width, min_color, min_width, max_color, max_width, plfill, 1, NULL, NULL ); plcol0( 1 ); plbox( "bcnst", 0.0, 0, "bcnstv", 0.0, 0 ); plcol0( 2 ); pllab( "distance", "altitude", "Bogon flux" ); }
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, 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 ); }
void shade(void) { int i, j; PLFLT x, y, argx, argy, distort; PLFLT **z, **w, zmin, zmax; PLFLT xg1[XPTS], yg1[YPTS]; PLcGrid cgrid1; PLcGrid2 cgrid2; PLFLT shade_min, shade_max, sh_color; PLINT sh_cmap = 1, sh_width; PLINT min_color = 1, min_width = 0, max_color = 0, max_width = 0; /* Set up function arrays */ plAlloc2dGrid(&z, XPTS, YPTS); plAlloc2dGrid(&w, XPTS, YPTS); /* Set up data array */ for (i = 0; i < XPTS; i++) { x = (double) (i - (XPTS / 2)) / (double) (XPTS / 2); for (j = 0; j < YPTS; j++) { y = (double) (j - (YPTS / 2)) / (double) (YPTS / 2) - 1.0; z[i][j] = - sin(7.*x) * cos(7.*y) + x*x - y*y; w[i][j] = - cos(7.*x) * sin(7.*y) + 2 * x * y; } } f2mnmx(z, XPTS, YPTS, &zmin, &zmax); for (i = 0; i < NCONTR; i++) clevel[i] = zmin + (zmax - zmin) * (i + 0.5) / (PLFLT) NCONTR; /* Set up coordinate grids */ cgrid1.xg = xg1; cgrid1.yg = yg1; cgrid1.nx = XPTS; cgrid1.ny = YPTS; plAlloc2dGrid(&cgrid2.xg, XPTS, YPTS); plAlloc2dGrid(&cgrid2.yg, XPTS, YPTS); cgrid2.nx = XPTS; cgrid2.ny = YPTS; for (i = 0; i < XPTS; i++) { for (j = 0; j < YPTS; j++) { mypltr((PLFLT) i, (PLFLT) j, &x, &y, NULL); argx = x * PI/2; argy = y * PI/2; distort = 0.4; cgrid1.xg[i] = x + distort * cos(argx); cgrid1.yg[j] = y - distort * cos(argy); cgrid2.xg[i][j] = x + distort * cos(argx) * cos(argy); cgrid2.yg[i][j] = y - distort * cos(argx) * cos(argy); } } /* Plot using identity transform */ pladv(0); plvpor(0.1, 0.9, 0.1, 0.9); plwind(-1.0, 1.0, -1.0, 1.0); for (i = 0; i < NCONTR; i++) { shade_min = zmin + (zmax - zmin) * i / (PLFLT) NCONTR; shade_max = zmin + (zmax - zmin) * (i +1) / (PLFLT) NCONTR; sh_color = i / (PLFLT) (NCONTR-1); sh_width = 2; plpsty(0); plshade(z, XPTS, YPTS, NULL, -1., 1., -1., 1., shade_min, shade_max, sh_cmap, sh_color, sh_width, min_color, min_width, max_color, max_width, plfill, 1, NULL, NULL); } plcol(1); plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0); plcol(2); /* plcont(w, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, NCONTR, mypltr, NULL); */ pllab("distance", "altitude", "Bogon density"); /* Clean up */ plFree2dGrid(z, XPTS, YPTS); plFree2dGrid(w, XPTS, YPTS); plFree2dGrid(cgrid2.xg, XPTS, YPTS); plFree2dGrid(cgrid2.yg, XPTS, YPTS); }
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 ); }