Example #1
0
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);
}
Example #2
0
void
plot3( void )
{
    PLINT space0 = 0, mark0 = 0, space1 = 1500, mark1 = 1500;
    int   i;

// For the final graph we wish to override the default tick intervals, and
// so do not use plenv().
//
    pladv( 0 );

// Use standard viewport, and define X range from 0 to 360 degrees, Y range
// from -1.2 to 1.2.
//
    plvsta();
    plwind( 0.0, 360.0, -1.2, 1.2 );

// Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.

    plcol0( 1 );
    plbox( "bcnst", 60.0, 2, "bcnstv", 0.2, 2 );

// Superimpose a dashed line grid, with 1.5 mm marks and spaces.
// plstyl expects a pointer!
//
    plstyl( 1, &mark1, &space1 );
    plcol0( 2 );
    plbox( "g", 30.0, 0, "g", 0.2, 0 );
    plstyl( 0, &mark0, &space0 );

    plcol0( 3 );
    pllab( "Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function" );

    for ( i = 0; i < 101; i++ )
    {
        x[i] = 3.6 * i;
        y[i] = sin( x[i] * M_PI / 180.0 );
    }

    plcol0( 4 );
    plline( 101, x, y );
}
Example #3
0
void
plot3( void )
{
    int i;

// For the final graph we wish to override the default tick intervals, and
// so do not use PLENV

    pladv( 0 );

// Use standard viewport, and define X range from 0 to 360 degrees, Y range
//     from -1.2 to 1.2.

    plvsta();
    plwind( (PLFLT) 0.0, (PLFLT) 360.0, (PLFLT) -1.2, (PLFLT) 1.2 );

// Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.

    plcol0( 1 );
    plbox( "bcnst", (PLFLT) 60.0, 2, "bcnstv", (PLFLT) 0.2, 2 );

// Superimpose a dashed line grid, with 1.5 mm marks and spaces. plstyl
// expects a pointer!!

    plstyl( 1, &mark1, &space1 );
    plcol0( 2 );
    plbox( "g", (PLFLT) 30.0, 0, "g", (PLFLT) 0.2, 0 );
    plstyl( 0, &mark0, &space0 );

    plcol0( 3 );
    pllab( "Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function" );

    for ( i = 0; i < 101; i++ )
    {
        x[i] = 3.6 * i;
        y[i] = sin( x[i] * 3.141592654 / 180.0 );
    }

    plcol0( 4 );
    plline( 101, x, y );
}
Example #4
0
static void plplot_set_window_size( plot_driver_type * driver , int width , int height) {
  char * geometry = util_alloc_sprintf("%dx%d", width, height);
  plsetopt("geometry", geometry);
  free( geometry );

  {
    plplot_state_type * state = driver->state;
    plsstrm( state->stream );  
    //{
    //  printf("---------- Calling plinit()\n");
    //  errno = 0;
    //  pllib_init();
    //  printf("%s: after plinit(): errno:%d  / strerror:%s\n",__func__ , errno , strerror( errno ));
    //}
    plinit();


    pladv(0);  /* And what does this do ... */
    plvsta();
  }
}
Example #5
0
static void
c_plenvi(PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax,
	PLINT just, PLINT axis, PLINT old)
{
    PLFLT lb, rb, tb, bb, dx, dy;
    PLFLT xsize, ysize, size, xscale, yscale, scale;
    PLFLT spxmin, spxmax, spymin, spymax;
    PLFLT vpxmin, vpxmax, vpymin, vpymax;

    if (plsc->level < 1) {
	plabort("plenv: Please call plinit first");
	return;
    }
    if (xmin == xmax) {
	plabort("plenv: Invalid xmin and xmax arguments");
	return;
    }
    if (ymin == ymax) {
	plabort("plenv: Invalid ymin and ymax arguments");
	return;
    }
    if (just < -1 || just > 2) {
	plabort("plenv: Invalid just option");
	return;
    }

    if (plsc->nsubx * plsc->nsuby == 1) /* not multiplot mode */
      old = 1;

    if (old == 1)
      pladv(0);
    else 
      plclear();

    if (just == 0)
	plvsta();
    else  if (just == 1){
	lb = 8.0 * plsc->chrht;
	rb = 5.0 * plsc->chrht;
	tb = 5.0 * plsc->chrht;
	bb = 5.0 * plsc->chrht;
	dx = ABS(xmax - xmin);
	dy = ABS(ymax - ymin);
	plgspa(&spxmin, &spxmax, &spymin, &spymax);
	xsize = spxmax - spxmin;
	ysize = spymax - spymin;
	xscale = dx / (xsize - lb - rb);
	yscale = dy / (ysize - tb - bb);
	scale = MAX(xscale, yscale);
	vpxmin = MAX(lb, 0.5 * (xsize - dx / scale));
	vpxmax = vpxmin + (dx / scale);
	vpymin = MAX(bb, 0.5 * (ysize - dy / scale));
	vpymax = vpymin + (dy / scale);
	plsvpa(vpxmin, vpxmax, vpymin, vpymax);
    } else if(just == 2) {
        lb = 8.0 * plsc->chrht;
        rb = 5.0 * plsc->chrht;
	tb = 5.0 * plsc->chrht;
	bb = 5.0 * plsc->chrht;
	plgspa(&spxmin, &spxmax, &spymin, &spymax);
	xsize = spxmax - spxmin;
	ysize = spymax - spymin;
	size = MIN(xsize-lb-rb, ysize-tb-bb);
	dx = (xsize-size-lb-rb)/2;
	vpxmin = lb + dx;
	vpxmax = vpxmin + size;
	dy = (ysize-size-bb-tb)/2;
	vpymin = bb + dy;
	vpymax = vpymin + size;
	plsvpa(vpxmin, vpxmax, vpymin, vpymax);
    }

    plwind(xmin, xmax, ymin, ymax);

    switch (axis) {
    case -2:
	break;
    case -1:
	plbox("bc", (PLFLT) 0.0, 0, "bc", (PLFLT) 0.0, 0);
	break;
    case 0:
	plbox("bcnst", (PLFLT) 0.0, 0, "bcnstv", (PLFLT) 0.0, 0);
	break;
    case 1:
	plbox("abcnst", (PLFLT) 0.0, 0, "abcnstv", (PLFLT) 0.0, 0);
	break;
    case 2:
	plbox("abcgnst", (PLFLT) 0.0, 0, "abcgnstv", (PLFLT) 0.0, 0);
	break;
    case 3:
	plbox("abcgnsth", (PLFLT) 0.0, 0, "abcgnstvh", (PLFLT) 0.0, 0);
	break;
    case 10:
	plbox("bclnst", (PLFLT) 0.0, 0, "bcnstv", (PLFLT) 0.0, 0);
	break;
    case 11:
	plbox("abclnst", (PLFLT) 0.0, 0, "abcnstv", (PLFLT) 0.0, 0);
	break;
    case 12:
	plbox("abcglnst", (PLFLT) 0.0, 0, "abcgnstv", (PLFLT) 0.0, 0);
	break;
    case 13:
	plbox("abcglnsth", (PLFLT) 0.0, 0, "abcgnstvh", (PLFLT) 0.0, 0);
	break;
    case 20:
	plbox("bcnst", (PLFLT) 0.0, 0, "bclnstv", (PLFLT) 0.0, 0);
	break;
    case 21:
	plbox("abcnst", (PLFLT) 0.0, 0, "abclnstv", (PLFLT) 0.0, 0);
	break;
    case 22:
	plbox("abcgnst", (PLFLT) 0.0, 0, "abcglnstv", (PLFLT) 0.0, 0);
	break;	
    case 23:
	plbox("abcgnsth", (PLFLT) 0.0, 0, "abcglnstvh", (PLFLT) 0.0, 0);
	break;	
    case 30:
	plbox("bclnst", (PLFLT) 0.0, 0, "bclnstv", (PLFLT) 0.0, 0);
	break;
    case 31:
	plbox("abclnst", (PLFLT) 0.0, 0, "abclnstv", (PLFLT) 0.0, 0);
	break;
    case 32:
	plbox("abcglnst", (PLFLT) 0.0, 0, "abcglnstv", (PLFLT) 0.0, 0);
	break;	
    case 33:
	plbox("abcglnsth", (PLFLT) 0.0, 0, "abcglnstvh", (PLFLT) 0.0, 0);
	break;	
    default:
	plwarn("plenv: Invalid axis argument");
    }
}
Example #6
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 );
}
Example #7
0
void plotall(int nlyr, double* T, double* plyr, double* z, double* deltaTday) {
#ifndef _NOPLOT
  /* Plot T against p */

  pladv(1);     /* select subpage 1  */
  plvsta();     /* standard viewport */
  plclear();    /* clear subpage     */
  plcol0 (15);  /* color black       */

  plwind( 0, 400, PSURF, 0 );  /* xmin, xmax, ymin, ymax */
  plbox( "bcnst", 100, 0, "bcnst", 150.0, 0 );
  pllab ("temperature [K]", "p [hPa]", "");  /* axis labels     */

  plcol0 (14);                         /* color blue  */
  plline (nlyr, T, plyr);  /* plot temperature profile  */

  plcol0 (15);                        /* color black */

  /* Plot T against z */

  pladv(3);     /* select subpage 1  */
  plvsta();     /* standard viewport */
  plclear();    /* clear subpage     */
  plcol0 (15);  /* color black       */

  plwind( 0, 400, 0, 40000 );  /* xmin, xmax, ymin, ymax */
  plbox( "bcnst", 100, 0, "bcnst", 5000.0, 0 );
  pllab ("temperature [K]", "z [m]", "");  /* axis labels     */

  plcol0 (14);                         /* color blue  */
  plline (nlyr, T, z);  /* plot temperature profile  */

  plcol0 (15);                        /* color black */

  /* Plot Heating rate against p */

  pladv(2);     /* select subpage 1  */
  plvsta();     /* standard viewport */
  plclear();    /* clear subpage     */
  plcol0 (15);  /* color black       */

  plwind( -20, 20, PSURF, 0 );  /* xmin, xmax, ymin, ymax */
  plbox( "bcnst", 2, 0, "bcnst", 150.0, 0 );
  pllab ("Heating Rate [T/day]", "p [hPa]", "");  /* axis labels     */

  plcol0 (12);                         /* color blue  */
  plline (nlyr, deltaTday, plyr);  /* plot temperature profile  */

  plcol0 (15);                        /* color black */


  /* Plot Heating rate against z */

  pladv(4);     /* select subpage 1  */
  plvsta();     /* standard viewport */
  plclear();    /* clear subpage     */
  plcol0 (15);  /* color black       */


  plwind( -20, 20, 0, 40000 );  /* xmin, xmax, ymin, ymax */
  plbox( "bcnst", 2, 0, "bcnst", 5000.0, 0 );
  pllab ("Heating Rate [T/day]", "z [m]", "");  /* axis labels     */

  plcol0 (12);                         /* color blue  */
  plline (nlyr, deltaTday, z);  /* plot temperature profile  */

  plcol0 (15);                        /* color black */
#endif
}
Example #8
0
void c_plstripa( PLINT id, PLINT p, PLFLT x, PLFLT y )
{
    int j, yasc=0, istart;

    if (p >= PEN) {
    	plabort("Non existent pen");
    	return;
    }

    if ((id < 0) || (id >= MAX_STRIPC) ||
	((stripc = strip[id]) == NULL)) {
    	plabort("Non existent stripchart");
    	return;
    }

/* Add new point, allocating memory if necessary */

    if (++stripc->npts[p] > stripc->nptsmax[p]) {
	stripc->nptsmax[p] += 32;
	stripc->x[p] = (PLFLT *) realloc((void *) stripc->x[p], sizeof(PLFLT)*stripc->nptsmax[p]);
	stripc->y[p] = (PLFLT *) realloc((void *) stripc->y[p], sizeof(PLFLT)*stripc->nptsmax[p]);
	if (stripc->x[p] == NULL || stripc->y[p] == NULL) {
	    plabort("plstripc: Out of memory.");
	    plstripd(id);
	    return;
	}
    }

    stripc->x[p][stripc->npts[p]-1] = x;
    stripc->y[p][stripc->npts[p]-1] = y;

    stripc->xmax = x;

    if (stripc->y_ascl == 1 && (y > stripc->ymax || y < stripc->ymin))
	yasc=1;

    if (y > stripc->ymax)
	stripc->ymax = stripc->ymin + 1.1*(y - stripc->ymin);
	if (y < stripc->ymin)
	  stripc->ymin = stripc->ymax - 1.1*(stripc->ymax - y);

/* Now either plot new point or regenerate plot */

        if (stripc->xmax - stripc->xmin < stripc->xlen) {
            if( yasc == 0) {

            /* If user has changed subwindow, make shure we have the correct one */
                plvsta();
                plwind(stripc->wxmin, stripc->wxmax, stripc->wymin, stripc->wymax); /* FIXME - can exist some redundancy here */
		plcol(stripc->colline[p]); pllsty(stripc->styline[p]);
		if ((stripc->npts[p]-2) < 0)
		  plP_movwor(stripc->x[p][stripc->npts[p]-1], stripc->y[p][stripc->npts[p]-1]);
		else
		  plP_movwor(stripc->x[p][stripc->npts[p]-2], stripc->y[p][stripc->npts[p]-2]);
		plP_drawor(stripc->x[p][stripc->npts[p]-1], stripc->y[p][stripc->npts[p]-1]);
		plflush();
            }
            else {
		stripc->xmax = stripc->xmin + stripc->xlen;
                plstrip_gen(stripc);
	    }
	}
    else {
/* Regenerating plot */
	if (stripc->acc == 0) {
	    for (j=0; j<PEN; j++) {
		if (stripc->npts[j] > 0) {
		    istart = 0;
		    while (stripc->x[j][istart] < stripc->xmin + stripc->xlen*stripc->xjump)
			istart++;

		    stripc->npts[j] = stripc->npts[j] - istart;
		    memcpy( &stripc->x[j][0], &stripc->x[j][istart], (stripc->npts[j])*sizeof(PLFLT));
		    memcpy( &stripc->y[j][0], &stripc->y[j][istart], (stripc->npts[j])*sizeof(PLFLT));
		}
	    }
	} else
	    stripc->xlen = stripc->xlen * (1 + stripc->xjump);

	stripc->xmin = stripc->x[p][0];
	stripc->xmax = stripc->xmax + stripc->xlen*stripc->xjump;

	plstrip_gen(stripc);
    }
}
Example #9
0
File: plp.c Project: a4a881d4/aloe
int plp_draw(double *signal, int *signal_lengths, int ylog_scale) {
	int count;
	int i,j;
	int col;
	int dowind;

	for (i=0;i<2*NOF_INPUT_ITF;i++) {
		if (signal_lengths[i] > INPUT_MAX_SAMPLES) {
			moderror_msg("plplot buffer configured for %d samples but received %d in signal %d\n",
					INPUT_MAX_SAMPLES,signal_lengths[i],i);
			return -1;
		}
	}

	dowind=0;
	xmax=-1;
	for(i=0;i<2*NOF_INPUT_ITF;i++) {
		if (signal_lengths[i]) {
			dowind=1;
			xmax = (PLFLT) MAX(xmax,signal_lengths[i]);
			for (j=0;j<signal_lengths[i];j++) {
				ymin = (PLFLT) MIN(ymin,signal[i*INPUT_MAX_SAMPLES+j]);
				ymax = (PLFLT) MAX(ymax,signal[i*INPUT_MAX_SAMPLES+j]);
			}
		}
	}

	if (!dowind) {
		xmin=0;
		xmax=100;
		ymin=-1;
		ymax=1;
	}

	plclear();

	plscolbg(255, 255, 255);
	plvsta();
	plwid(1);
	plwind(xmin, xmax, ymin*1.1, ymax*1.1);

	plcol0(1);
	if (ylog_scale) {
		plbox(logaxis_x, 0., 0, logaxis_y, 0., 0);
	} else {
		plbox(axis_x, 0., 0, axis_y, 0., 0);
	}
	plcol0(4);
	plbox("g", 0, 0, "g", 0, 0);
	plcol0(1);
	pllab(xlabel, ylabel, "");

	draw_legend();

	plwid(4);
	col=3;
	for (i=0;i<2*NOF_INPUT_ITF;i++) {
		if (signal_lengths[i]) {
			plcol0(line_colors[i]);
			plline(signal_lengths[i], t, &signal[i*INPUT_MAX_SAMPLES]);
			col++;
			if (col==4) col++;
		}
	}

	plflush();                      // force an update of the tk driver

}