void initialize_colors( void ) { plscol0( 0, 255, 255, 255 ); plscol0( 1, 0, 0, 0 ); plscol0( 2, 255, 0, 0 ); plscol0a( 3, 0, 0, 255, 0.3 ); }
int plp_init(const char *driver, const char *_title, int _is_complex) { int i; if (2*NOF_INPUT_ITF > 1) { modinfo("Multiple signals are currently displayed in the same plot\n"); } plsdev(driver); plinit(); pladv(0); title = _title; is_complex = _is_complex; for (i=0;i<2*NOF_INPUT_ITF;i++) { legends[i] = (const char*) ""; } for (i=0;i<INPUT_MAX_SAMPLES;i++) { t[i] = i; } setup_legend(); xlabel = xlabel_def; ylabel = ylabel_def; plscol0a( 14, 0, 0, 0, 1); reset_axis(); return 0; }
void plot1( int type, const char *x_label, const char *y_label, const char *alty_label, const char * legend_text[], const char *title_label, const char *line_label ) { int i; static PLFLT freql[101], ampl[101], phase[101]; PLFLT f0, freq; PLINT nlegend = 2; PLINT opt_array[2]; PLINT text_colors[2]; PLINT line_colors[2]; PLINT line_styles[2]; PLFLT line_widths[2]; PLINT symbol_numbers[2], symbol_colors[2]; PLFLT symbol_scales[2]; const char *symbols[2]; PLFLT legend_width, legend_height; pladv( 0 ); // Set up data for log plot f0 = 1.0; for ( i = 0; i <= 100; i++ ) { freql[i] = -2.0 + i / 20.0; freq = pow( 10.0, freql[i] ); ampl[i] = 20.0 * log10( 1.0 / sqrt( 1.0 + pow( ( freq / f0 ), 2. ) ) ); phase[i] = -( 180.0 / M_PI ) * atan( freq / f0 ); } plvpor( 0.15, 0.85, 0.1, 0.9 ); plwind( -2.0, 3.0, -80.0, 0.0 ); // Try different axis and labelling styles. plcol0( 1 ); switch ( type ) { case 0: plbox( "bclnst", 0.0, 0, "bnstv", 0.0, 0 ); break; case 1: plbox( "bcfghlnst", 0.0, 0, "bcghnstv", 0.0, 0 ); break; } // Plot ampl vs freq plcol0( 2 ); plline( 101, freql, ampl ); plcol0( 2 ); plptex( 1.6, -30.0, 1.0, -20.0, 0.5, line_label ); // Put labels on plcol0( 1 ); plmtex( "b", 3.2, 0.5, 0.5, x_label ); plmtex( "t", 2.0, 0.5, 0.5, title_label ); plcol0( 2 ); plmtex( "l", 5.0, 0.5, 0.5, y_label ); // For the gridless case, put phase vs freq on same plot if ( type == 0 ) { plcol0( 1 ); plwind( -2.0, 3.0, -100.0, 0.0 ); plbox( "", 0.0, 0, "cmstv", 30.0, 3 ); plcol0( 3 ); plline( 101, freql, phase ); plstring( 101, freql, phase, "#(728)" ); plcol0( 3 ); plmtex( "r", 5.0, 0.5, 0.5, alty_label ); } // Draw a legend // First legend entry. opt_array[0] = PL_LEGEND_LINE; text_colors[0] = 2; line_colors[0] = 2; line_styles[0] = 1; line_widths[0] = 1.; // note from the above opt_array the first symbol (and box) indices // do not have to be specified // Second legend entry. opt_array[1] = PL_LEGEND_LINE | PL_LEGEND_SYMBOL; text_colors[1] = 3; line_colors[1] = 3; line_styles[1] = 1; line_widths[1] = 1.; symbol_colors[1] = 3; symbol_scales[1] = 1.; symbol_numbers[1] = 4; symbols[1] = "#(728)"; // from the above opt_arrays we can completely ignore everything // to do with boxes. plscol0a( 15, 32, 32, 32, 0.70 ); pllegend( &legend_width, &legend_height, PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, 0, 0.0, 0.0, 0.10, 15, 1, 1, 0, 0, nlegend, opt_array, 1.0, 1.0, 2.0, 1., text_colors, (const char **) legend_text, NULL, NULL, NULL, NULL, line_colors, line_styles, line_widths, symbol_colors, symbol_scales, symbol_numbers, (const char **) symbols ); }