From: <and...@us...> - 2009-01-09 00:48:55
|
Revision: 9287 http://plplot.svn.sourceforge.net/plplot/?rev=9287&view=rev Author: andrewross Date: 2009-01-09 00:48:43 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Update example 12 so it actually does use plcol1, as documented in api.xml. Previously it was commented out. Set up a colour map to use with this. Modified Paths: -------------- trunk/bindings/octave/demos/x12c.m trunk/examples/ada/x12a.adb.cmake trunk/examples/ada/xthick12a.adb.cmake trunk/examples/c/x12c.c trunk/examples/c++/x12.cc trunk/examples/f77/x12f.fm4 trunk/examples/f95/x12f.f90 trunk/examples/java/x12.java trunk/examples/ocaml/x12.ml trunk/examples/perl/x12.pl trunk/examples/python/xw12.py trunk/examples/tcl/x12.tcl Modified: trunk/bindings/octave/demos/x12c.m =================================================================== --- trunk/bindings/octave/demos/x12c.m 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/bindings/octave/demos/x12c.m 2009-01-09 00:48:43 UTC (rev 9287) @@ -45,10 +45,18 @@ y0 = [5; 15; 12; 24; 28;30; 20; 8; 12; 3]; + pos = [0.0; 0.25; 0.5; 0.75; 1.0]; + red = [0.0; 0.25; 0.5; 1.00; 1.0]; + green = [1.0; 0.50; 0.5; 0.50; 1.0]; + blue = [1.0; 1.0; 0.5; 0.25; 0.0]; + rev = [0; 0; 0; 0; 0]; + + plscmap1l(1,pos,red,green,blue,rev); + for i=0:9 - plcol(i + 1); + ##plcol(i + 1); - ## plcol1((PLFLT) ((i + 1)/10.0)); + plcol1(i/9.0); plpsty(0); plfbox((1980. + i), y0(i+1)); Modified: trunk/examples/ada/x12a.adb.cmake =================================================================== --- trunk/examples/ada/x12a.adb.cmake 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/ada/x12a.adb.cmake 2009-01-09 00:48:43 UTC (rev 9287) @@ -36,7 +36,7 @@ PLplot_Auxiliary, PLplot_Traditional; --- COMMENT THIS LINE IF YOUR COMPILER DOES NOT INCLUDE THESE +-- COMMENT THIS LINE IF YOUR COMPILER DOES NOT INCLUDE THESE -- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. --with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; @Ada_Is_2007_With_and_Use_Numerics@ @@ -48,6 +48,12 @@ procedure x12a is y0 : Real_Vector (0 .. 9); + + pos : Real_Vector (0 .. 4) := (0.0, 0.25, 0.5, 0.75, 1.0); + red : Real_Vector (0 .. 4) := (0.0, 0.25, 0.5, 1.0, 1.0); + green : Real_Vector (0 .. 4) := (1.0, 0.5, 0.5, 0.5, 1.0); + blue : Real_Vector (0 .. 4) := (1.0, 1.0, 0.5, 0.25, 0.0); + A_Boolean :Boolean_Array_1D(0 .. 4) := (False, False, False, False, False); procedure plfbox (x0, y0 : Long_Float) is x, y : Real_Vector (0 ..3); @@ -69,10 +75,10 @@ pllsty(1); plline(x, y); end plfbox; - + begin -- Parse and process command line arguments. - plparseopts(PL_PARSE_FULL); + plparseopts(PL_PARSE_FULL); -- Initialize plplot. plinit; @@ -95,8 +101,11 @@ y0(8) := 12.0; y0(9) := 3.0; + plscmap1l(RGB, pos, red, green, blue, A_Boolean); + for i in y0'range loop - plcol0(i + 1); + -- plcol0(i + 1); + plcol1(Long_Float(i)/9.0); plpsty(0); plfbox((1980.0 + Long_Float(i)), y0(i)); plptex(1980.0 + Long_Float(i) + 0.5, y0(i) + 1.0, 1.0, 0.0, 0.5, Trim(Integer'image(Integer(y0(i))), Left)); Modified: trunk/examples/ada/xthick12a.adb.cmake =================================================================== --- trunk/examples/ada/xthick12a.adb.cmake 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/ada/xthick12a.adb.cmake 2009-01-09 00:48:43 UTC (rev 9287) @@ -47,6 +47,12 @@ procedure xthick12a is y0 : Real_Vector (0 .. 9); + + pos : Real_Vector (0 .. 4) := (0.0, 0.25, 0.5, 0.75, 1.0); + r : Real_Vector (0 .. 4) := (0.0, 0.25, 0.5, 1.0, 1.0); + g : Real_Vector (0 .. 4) := (1.0, 0.5, 0.5, 0.5, 1.0); + b : Real_Vector (0 .. 4) := (1.0, 1.0, 0.5, 0.25, 0.0); + A_Boolean :Boolean_Array_1D(0 .. 4) := (False, False, False, False, False); procedure plfbox (x0, y0 : Long_Float) is x, y : Real_Vector (0 ..3); @@ -69,7 +75,7 @@ Draw_Curve(x, y); end plfbox; -begin + begin -- Parse and process command line arguments. Parse_Command_Line_Arguments(Parse_Full); @@ -94,8 +100,11 @@ y0(8) := 12.0; y0(9) := 3.0; + Set_Color_Map_1_Piecewise(RGB, pos, r, g, b, A_Boolean); + for i in y0'range loop - Set_Pen_Color(i + 1); + --Set_Pen_Color(i + 1); + Set_Color_Map_1(Long_Float(i)/9.0); Select_Fill_Pattern(0); plfbox((1980.0 + Long_Float(i)), y0(i)); Write_Text_World(1980.0 + Long_Float(i) + 0.5, y0(i) + 1.0, 1.0, 0.0, 0.5, Trim(Integer'image(Integer(y0(i))), Left)); Modified: trunk/examples/c/x12c.c =================================================================== --- trunk/examples/c/x12c.c 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/c/x12c.c 2009-01-09 00:48:43 UTC (rev 9287) @@ -22,6 +22,11 @@ char string[20]; PLFLT y0[10]; + static PLFLT pos[] = {0.0, 0.25, 0.5, 0.75, 1.0}; + static PLFLT red[] = {0.0, 0.25, 0.5, 1.0, 1.0}; + static PLFLT green[] = {1.0, 0.5, 0.5, 0.5, 1.0}; + static PLFLT blue[] = {1.0, 1.0, 0.5, 0.25, 0.0}; + /* Parse and process command line arguments */ (void) plparseopts(&argc, argv, PL_PARSE_FULL); @@ -48,11 +53,11 @@ y0[8] = 12; y0[9] = 3; + plscmap1l(1,5,pos,red,green,blue,NULL); + for (i = 0; i < 10; i++) { - plcol0(i + 1); - /* - plcol1((PLFLT) ((i + 1)/10.0)); - */ + /*plcol0(i + 1);*/ + plcol1(i/9.0); plpsty(0); plfbox((1980. + i), y0[i]); sprintf(string, "%.0f", y0[i]); Modified: trunk/examples/c++/x12.cc =================================================================== --- trunk/examples/c++/x12.cc 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/c++/x12.cc 2009-01-09 00:48:43 UTC (rev 9287) @@ -42,11 +42,17 @@ static const PLFLT y0[]; + static PLFLT pos[], red[], green[], blue[]; }; const PLFLT x12::y0[10] = {5., 15., 12., 24., 28., 30., 20., 8., 12., 3.}; +PLFLT x12::pos[] = {0.0, 0.25, 0.5, 0.75, 1.0}; +PLFLT x12::red[] = {0.0, 0.25, 0.5, 1.0, 1.0}; +PLFLT x12::green[] = {1.0, 0.5, 0.5, 0.5, 1.0}; +PLFLT x12::blue[] = {1.0, 1.0, 0.5, 0.25, 0.0}; + x12::x12( int argc, const char **argv ) { int i; @@ -71,9 +77,12 @@ pls->box("bc", 1.0, 0, "bcnv", 10.0, 0); pls->col0(2); pls->lab("Year", "Widget Sales (millions)", "#frPLplot Example 12"); + + pls->scmap1l(true,5,pos,red,green,blue,NULL); + for (i = 0; i < 10; i++) { - pls->col0(i + 1); - // pls->col1((PLFLT) ((i + 1)/10.0)); + //pls->col0(i + 1); + pls->col1(i/9.0); pls->psty(0); plfbox((1980. + i), y0[i]); sprintf(string, "%.0f", y0[i]); Modified: trunk/examples/f77/x12f.fm4 =================================================================== --- trunk/examples/f77/x12f.fm4 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/f77/x12f.fm4 2009-01-09 00:48:43 UTC (rev 9287) @@ -24,8 +24,17 @@ character*20 string integer i real*8 y0(10) + real*8 pos(5), rcoord(5), gcoord(5), bcoord(5) + integer rev(5) integer PL_PARSE_FULL parameter(PL_PARSE_FULL = 1) + + data pos /0.0d0, 0.25d0, 0.5d0, 0.75d0, 1.0d0/ + data rcoord /0.0d0, 0.25d0, 0.5d0, 1.0d0, 1.0d0/ + data gcoord /1.0d0, 0.5d0, 0.5d0, 0.5d0, 1.0d0/ + data bcoord /1.0d0, 1.0d0, 0.5d0, 0.25d0, 0.0d0/ + data rev /0, 0, 0, 0, 0/ + C Process command-line arguments call plparseopts(PL_PARSE_FULL) @@ -50,8 +59,11 @@ y0(9) = 12 y0(10) = 3 + call plscmap1l(1,5,pos,rcoord,gcoord,bcoord,rev) + do i = 0, 9 - call plcol0(i + 1) +C call plcol0(i + 1) + call plcol1(dble(i)/9.0d0) call plpsty(0) call plfbox( dble (1980.d0+i), y0(i+1) ) write (string, '(i8)')int(y0(i+1)) Modified: trunk/examples/f95/x12f.f90 =================================================================== --- trunk/examples/f95/x12f.f90 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/f95/x12f.f90 2009-01-09 00:48:43 UTC (rev 9287) @@ -25,6 +25,13 @@ character*20 string integer i real(kind=plflt) y0(10) + real(kind=plflt) pos(5), red(5), green(5), blue(5) + + data pos /0.0_plflt, 0.25_plflt, 0.5_plflt, 0.75_plflt, 1.0_plflt/ + data red /0.0_plflt, 0.25_plflt, 0.5_plflt, 1.0_plflt, 1.0_plflt/ + data green /1.0_plflt, 0.5_plflt, 0.5_plflt, 0.5_plflt, 1.0_plflt/ + data blue /1.0_plflt, 1.0_plflt, 0.5_plflt, 0.25_plflt, 0.0_plflt/ + ! Process command-line arguments call plparseopts(PL_PARSE_FULL) @@ -48,9 +55,12 @@ y0(8) = 8 y0(9) = 12 y0(10) = 3 + + call plscmap1l(.true.,pos,red,green,blue) do i = 0, 9 - call plcol0(i + 1) +! call plcol0(i + 1) + call plcol1(dble(i)/9.0_plflt) call plpsty(0) call plfbox( 1980._plflt+i, y0(i+1) ) write (string, '(i8)')int(y0(i+1)) Modified: trunk/examples/java/x12.java =================================================================== --- trunk/examples/java/x12.java 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/java/x12.java 2009-01-09 00:48:43 UTC (rev 9287) @@ -36,6 +36,12 @@ class x12 { static double y0[] = {5., 15., 12., 24., 28., 30., 20., 8., 12., 3.}; + + static double[] pos = {0.0, 0.25, 0.5, 0.75, 1.0}; + static double[] red = {0.0, 0.25, 0.5, 1.0, 1.0}; + static double[] green = {1.0, 0.5, 0.5, 0.5, 1.0}; + static double[] blue = {1.0, 1.0, 0.5, 0.25, 0.0}; + PLStream pls = new PLStream(); @@ -62,9 +68,12 @@ pls.box("bc", 1.0, 0, "bcnv", 10.0, 0); pls.col0(2); pls.lab("Year", "Widget Sales (millions)", "#frPLplot Example 12"); + + pls.scmap1l(true,pos,red,green,blue); + for (i = 0; i < 10; i++) { - pls.col0(i + 1); -// pls.col1((double) ((i + 1)/10.0)); +// pls.col0(i + 1); + pls.col1((double) i/9.0); pls.psty(0); plfbox((1980. + i), y0[i]); // sprintf(string, "%.0f", y0[i]); Modified: trunk/examples/ocaml/x12.ml =================================================================== --- trunk/examples/ocaml/x12.ml 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/ocaml/x12.ml 2009-01-09 00:48:43 UTC (rev 9287) @@ -18,6 +18,11 @@ * unavailable, pattern fill is used instead (automatic). \*--------------------------------------------------------------------------*) +let pos = [|0.0; 0.25; 0.5; 0.75; 1.0|] +let red = [|0.0; 0.25; 0.5; 1.00; 1.0|] +let green = [|1.0; 0.50; 0.5; 0.50; 1.0|] +let blue = [|1.0; 1.0; 0.5; 0.25; 0.0|] + let () = (* Parse and process command line arguments *) ignore (plparseopts Sys.argv [PL_PARSE_FULL]); @@ -34,8 +39,11 @@ let y0 = [|5.0; 15.0; 12.0; 24.0; 28.0; 30.0; 20.0; 8.0; 12.0; 3.0|] in + plscmap1l true pos red green blue None; + for i = 0 to 9 do - plcol0 (i + 1); + (* plcol0 (i + 1); *) + plcol1(float_of_int i /. 9.0); plpsty 0; plfbox (1980.0 +. float_of_int i) y0.(i); let text = Printf.sprintf "%.0f" y0.(i) in Modified: trunk/examples/perl/x12.pl =================================================================== --- trunk/examples/perl/x12.pl 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/perl/x12.pl 2009-01-09 00:48:43 UTC (rev 9287) @@ -27,6 +27,11 @@ use PDL; use PDL::Graphics::PLplot; +my $pos = double (0.0, 0.25, 0.5, 0.75, 1.0); +my $red = double (0.0, 0.25, 0.5, 1.0, 1.0); +my $green = double (1.0, 0.5, 0.5, 0.5, 1.0); +my $blue = double (1.0, 1.0, 0.5, 0.25, 0.0); + # Parse and process command line arguments plParseOpts (\@ARGV, PL_PARSE_SKIP | PL_PARSE_NOPROGRAM); @@ -45,8 +50,11 @@ my $y0 = pdl [5, 15, 12, 24, 28, 30, 20, 8, 12, 3]; +plscmap1l(1, $pos, $red, $green, $blue, pdl []); + for (my $i = 0; $i < 10; $i++) { - plcol0 ($i + 1); + # plcol0 ($i + 1); + plcol1 ($i/9.0); plpsty (0); myplfbox ((1980. + $i), $y0->index ($i)); my $string = sprintf ("%.0f", $y0->index ($i)); Modified: trunk/examples/python/xw12.py =================================================================== --- trunk/examples/python/xw12.py 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/python/xw12.py 2009-01-09 00:48:43 UTC (rev 9287) @@ -30,6 +30,11 @@ def main(): + pos = array ([0.0, 0.25, 0.5, 0.75, 1.0]) + red = array ([0.0, 0.25, 0.5, 1.0, 1.0]) + green = array ([1.0, 0.5, 0.5, 0.5, 1.0]) + blue = array ([1.0, 1.0, 0.5, 0.25, 0.0]) + pladv(0) plvsta() plwind(1980.0, 1990.0, 0.0, 35.0) @@ -39,8 +44,11 @@ y0 = [5, 15, 12, 24, 28, 30, 20, 8, 12, 3] + plscmap1l(1, pos, red, green, blue) + for i in range(10): - plcol0(i + 1) + # plcol0(i + 1) + plcol1(i / 9.0) plpsty(0) fbox( (1980. + i), y0[i] ) string = `y0[i]` Modified: trunk/examples/tcl/x12.tcl =================================================================== --- trunk/examples/tcl/x12.tcl 2009-01-09 00:25:36 UTC (rev 9286) +++ trunk/examples/tcl/x12.tcl 2009-01-09 00:48:43 UTC (rev 9287) @@ -9,6 +9,12 @@ matrix y0 f 10 = {5., 15., 12., 24., 28., 30., 20., 8., 12., 3.} + matrix pos f 5 = {0.0, 0.25, 0.5, 0.75, 1.0} + matrix red f 5 = {0.0, 0.25, 0.5, 1.0, 1.0} + matrix green f 5 = {1.0, 0.5, 0.5, 0.5, 1.0} + matrix blue f 5 = {1.0, 1.0, 0.5, 0.25, 0.0} + matrix rev i 5 = {0, 0, 0, 0, 0} + $w cmd pladv 0 $w cmd plvsta $w cmd plwind 1980.0 1990.0 0.0 35.0 @@ -16,10 +22,12 @@ $w cmd plcol0 2 $w cmd pllab "Year" "Widget Sales (millions)" "#frPLplot Example 12" + $w cmd plscmap1l 1 5 pos red green blue rev + for {set i 0} {$i < 10} {incr i} { - $w cmd plcol0 [expr $i+1] +# $w cmd plcol0 [expr $i+1] -# $w cmd plcol1 [expr ($i + 1.)/10.0 ] + $w cmd plcol1 [expr ($i / 9.0) ] $w cmd plpsty 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |