static plplot_state_type * plplot_state_alloc( const void * init_arg ) { plplot_state_type * state = util_malloc( sizeof * state ); state->stream = 0; { const arg_pack_type * arg_pack = arg_pack_safe_cast_const( init_arg ); state->filename = util_alloc_string_copy( arg_pack_iget_const_ptr( arg_pack , 0) ); state->device = util_alloc_string_copy( arg_pack_iget_const_ptr( arg_pack , 1) ); plsstrm(state->stream); plsdev(state->device); /* Can this be NULL?? */ if (strcmp(state->device , "xwin") != 0) plsfnam(state->filename); } state->logx = false; state->logy = false; state->plbox_xopt = util_alloc_string_copy( PLOT_DEFAULT_PLBOX_XOPT ); state->plbox_yopt = util_alloc_string_copy( PLOT_DEFAULT_PLBOX_YOPT ); /** This color initialization must be here - do not really understand what for. */ plscol0(WHITE, 255, 255, 255); plscol0(BLACK, 0, 0, 0); plfontld(0); //plinit(); return state; }
int main( int argc, char *argv[] ) { PLINT digmax, cur_strm, new_strm; char ver[80]; // plplot initialization // Parse and process command line arguments plMergeOpts( options, "x01c options", notes ); plparseopts( &argc, argv, PL_PARSE_FULL ); // Get version number, just for kicks plgver( ver ); fprintf( stdout, "PLplot library version: %s\n", ver ); // Initialize plplot // Divide page into 2x2 plots // Note: calling plstar replaces separate calls to plssub and plinit plstar( 2, 2 ); // Select font set as per input flag if ( fontset ) plfontld( 1 ); else plfontld( 0 ); // Set up the data // Original case xscale = 6.; yscale = 1.; xoff = 0.; yoff = 0.; // Do a plot plot1( 0 ); // Set up the data xscale = 1.; yscale = 0.0014; yoff = 0.0185; // Do a plot digmax = 5; plsyax( digmax, 0 ); plot1( 1 ); plot2(); plot3(); // // Show how to save a plot: // Open a new device, make it current, copy parameters, // and replay the plot buffer // if ( f_name ) // command line option '-save filename' { printf( "The current plot was saved in color Postscript under the name `%s'.\n", f_name ); plgstrm( &cur_strm ); // get current stream plmkstrm( &new_strm ); // create a new one plsfnam( f_name ); // file name plsdev( "psc" ); // device type plcpstrm( cur_strm, 0 ); // copy old stream parameters to new stream plreplot(); // do the save by replaying the plot buffer plend1(); // finish the device plsstrm( cur_strm ); // return to previous stream } // Let's get some user input if ( locate_mode ) { for (;; ) { if ( !plGetCursor( &gin ) ) break; if ( gin.keysym == PLK_Escape ) break; pltext(); printf( "subwin = %d, wx = %f, wy = %f, dx = %f, dy = %f\n", gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY ); printf( "keysym = 0x%02x, button = 0x%02x, string = '%s', type = 0x%02x, state = 0x%02x\n", gin.keysym, gin.button, gin.string, gin.type, gin.state ); plgra(); } } // Don't forget to call plend() to finish off! plend(); exit( 0 ); }
int main( int argc, const char *argv[] ) { char text[10]; int i, j, k, l; PLFLT x, y; // Parse and process command line arguments (void) plparseopts( &argc, argv, PL_PARSE_FULL ); // Initialize plplot plinit(); plfontld( 0 ); for ( l = 0; l < 20; l++ ) { if ( l == 2 ) plfontld( 1 ); pladv( 0 ); // Set up viewport and window plcol0( 2 ); plvpor( 0.15, 0.95, 0.1, 0.9 ); plwind( 0.0, 1.0, 0.0, 1.0 ); // Draw the grid using plbox plbox( "bcg", 0.1, 0, "bcg", 0.1, 0 ); // Write the digits below the frame plcol0( 15 ); for ( i = 0; i <= 9; i++ ) { sprintf( text, "%d", i ); plmtex( "b", 1.5, ( 0.1 * i + 0.05 ), 0.5, text ); } k = 0; for ( i = 0; i <= 9; i++ ) { // Write the digits to the left of the frame sprintf( text, "%d", base[l] + 10 * i ); plmtex( "lv", 1.0, ( 0.95 - 0.1 * i ), 1.0, text ); for ( j = 0; j <= 9; j++ ) { x = 0.1 * j + 0.05; y = 0.95 - 0.1 * i; // Display the symbols plsym( 1, &x, &y, base[l] + k ); k = k + 1; } } if ( l < 2 ) plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (compact)" ); else plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (extended)" ); } plend(); exit( 0 ); }