From: <ai...@us...> - 2008-10-14 22:20:18
|
Revision: 8908 http://plplot.svn.sourceforge.net/plplot/?rev=8908&view=rev Author: airwin Date: 2008-10-14 22:20:08 +0000 (Tue, 14 Oct 2008) Log Message: ----------- Change all versions of standard example 3 to use justification for labelling that looks better. All results compared the same except for the ocaml one where I need some help from Hez to deal with the changed OCaml logic that is needed. Modified Paths: -------------- trunk/bindings/octave/demos/x03c.m trunk/examples/ada/x03a.adb.cmake trunk/examples/ada/xthick03a.adb.cmake trunk/examples/c/x03c.c trunk/examples/c++/x03.cc trunk/examples/d/x03d.d trunk/examples/f77/x03f.fm4 trunk/examples/f95/x03f.f90 trunk/examples/java/x03.java trunk/examples/ocaml/x03.ml trunk/examples/perl/x03.pl trunk/examples/python/xw03.py trunk/examples/tcl/x03.tcl Modified: trunk/bindings/octave/demos/x03c.m =================================================================== --- trunk/bindings/octave/demos/x03c.m 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/bindings/octave/demos/x03c.m 2008-10-14 22:20:08 UTC (rev 8908) @@ -63,10 +63,17 @@ ## Write labels for angle */ + if (theta < 9.99) + offset = 0.45; + elseif (theta < 99.9) + offset = 0.30; + else + offset = 0.15; + endif if (dx >= -0.00001) - plptex(dx, dy, dx, dy, -0.15, text); + plptex(dx, dy, dx, dy, -offset, text); else - plptex(dx, dy, -dx, -dy, 1.15, text); + plptex(dx, dy, -dx, -dy, 1.+offset, text); endif endfor Modified: trunk/examples/ada/x03a.adb.cmake =================================================================== --- trunk/examples/ada/x03a.adb.cmake 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/ada/x03a.adb.cmake 2008-10-14 22:20:08 UTC (rev 8908) @@ -42,7 +42,7 @@ @Ada_Is_2007_With_and_Use_Numerics@ procedure x03a is - dtr, theta, dx, dy, r : Long_Float; + dtr, theta, dx, dy, r, offset : Long_Float; x0, y0 : Real_Vector(0..360); x, y : Real_Vector(0..360); @@ -81,11 +81,20 @@ pljoin(0.0, 0.0, dx, dy); -- Write labels for angle. + + if theta < 9.99 then + offset := 0.45; + elsif theta < 99.9 then + offset := 0.30; + else + offset := 0.15; + end if; + -- Slightly off zero to avoid floating point logic flips at 90 and 270 deg if dx >= -0.00001 then - plptex(dx, dy, dx, dy, -0.15, Trim(Integer'image(Integer(theta)), Left)); + plptex(dx, dy, dx, dy, -offset, Trim(Integer'image(Integer(theta)), Left)); else - plptex(dx, dy, -dx, -dy, 1.15, Trim(Integer'image(Integer(theta)), Left)); + plptex(dx, dy, -dx, -dy, 1.0 + offset, Trim(Integer'image(Integer(theta)), Left)); end if; end loop; Modified: trunk/examples/ada/xthick03a.adb.cmake =================================================================== --- trunk/examples/ada/xthick03a.adb.cmake 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/ada/xthick03a.adb.cmake 2008-10-14 22:20:08 UTC (rev 8908) @@ -42,7 +42,7 @@ @Ada_Is_2007_With_and_Use_Numerics@ procedure xthick03a is - dtr, theta, dx, dy, r : Long_Float; + dtr, theta, dx, dy, r, offset : Long_Float; x0, y0 : Real_Vector(0..360); x, y : Real_Vector(0..360); @@ -81,11 +81,20 @@ Draw_Line(0.0, 0.0, dx, dy); -- Write labels for angle. + + if theta < 9.99 then + offset := 0.45; + elsif theta < 99.9 then + offset := 0.30; + else + offset := 0.15; + end if; + -- Slightly off zero to avoid floating point logic flips at 90 and 270 deg if dx >= -0.00001 then - Write_Text_World(dx, dy, dx, dy, -0.15, Trim(Integer'image(Integer(theta)), Left)); + Write_Text_World(dx, dy, dx, dy, -offset, Trim(Integer'image(Integer(theta)), Left)); else - Write_Text_World(dx, dy, -dx, -dy, 1.15, Trim(Integer'image(Integer(theta)), Left)); + Write_Text_World(dx, dy, -dx, -dy, 1.0 + offset, Trim(Integer'image(Integer(theta)), Left)); end if; end loop; Modified: trunk/examples/c/x03c.c =================================================================== --- trunk/examples/c/x03c.c 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/c/x03c.c 2008-10-14 22:20:08 UTC (rev 8908) @@ -15,7 +15,7 @@ main(int argc, const char *argv[]) { int i, j; - PLFLT dtr, theta, dx, dy, r; + PLFLT dtr, theta, dx, dy, r, offset; char text[4]; static PLFLT x0[361], y0[361]; static PLFLT x[361], y[361]; @@ -61,11 +61,19 @@ /* Write labels for angle */ + if (theta < 9.99) { + offset = 0.45; + } else if (theta < 99.9) { + offset = 0.30; + } else { + offset = 0.15; + } + /* Slightly off zero to avoid floating point logic flips at 90 and 270 deg. */ if (dx >= -0.00001) - plptex(dx, dy, dx, dy, -0.15, text); + plptex(dx, dy, dx, dy, -offset, text); else - plptex(dx, dy, -dx, -dy, 1.15, text); + plptex(dx, dy, -dx, -dy, 1.+offset, text); } /* Draw the graph */ Modified: trunk/examples/c++/x03.cc =================================================================== --- trunk/examples/c++/x03.cc 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/c++/x03.cc 2008-10-14 22:20:08 UTC (rev 8908) @@ -49,7 +49,7 @@ int i, j; char text[4]; - PLFLT dtr, theta, dx, dy, r; + PLFLT dtr, theta, dx, dy, r, offset; PLFLT *x0 = new PLFLT[361]; PLFLT *y0 = new PLFLT[361]; @@ -100,11 +100,19 @@ // Write labels for angle. + if (theta < 9.99) { + offset = 0.45; + } else if (theta < 99.9) { + offset = 0.30; + } else { + offset = 0.15; + } + //Slightly off zero to avoid floating point logic flips at 90 and 270 deg. if (dx >= -0.00001) - pls->ptex(dx, dy, dx, dy, -0.15, text); + pls->ptex(dx, dy, dx, dy, -offset, text); else - pls->ptex(dx, dy, -dx, -dy, 1.15, text); + pls->ptex(dx, dy, -dx, -dy, 1.+offset, text); } // Draw the graph. Modified: trunk/examples/d/x03d.d =================================================================== --- trunk/examples/d/x03d.d 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/d/x03d.d 2008-10-14 22:20:08 UTC (rev 8908) @@ -14,7 +14,7 @@ \*--------------------------------------------------------------------------*/ int main( char[][] args ) { - PLFLT dtr, theta, dx, dy, r; + PLFLT dtr, theta, dx, dy, r, offset; char[] text; PLFLT[361] x0, y0; PLFLT[361] x, y; @@ -59,11 +59,20 @@ text = format( "%.0f", round(theta) ); /* Write labels for angle */ + + if (theta < 9.99) { + offset = 0.45; + } else if (theta < 99.9) { + offset = 0.30; + } else { + offset = 0.15; + } + /* Slightly off zero to avoid floating point logic flips at 90 and 270 deg. */ if( dx>=-0.00001 ) - plptex( dx, dy, dx, dy, -0.15, toStringz(text) ); + plptex( dx, dy, dx, dy, -offset, toStringz(text) ); else - plptex(dx, dy, -dx, -dy, 1.15, toStringz(text) ); + plptex(dx, dy, -dx, -dy, 1.+offset, toStringz(text) ); } /* Draw the graph */ Modified: trunk/examples/f77/x03f.fm4 =================================================================== --- trunk/examples/f77/x03f.fm4 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/f77/x03f.fm4 2008-10-14 22:20:08 UTC (rev 8908) @@ -25,7 +25,7 @@ character*3 text real*8 x0(0:360), y0(0:360) - real*8 x(0:360), y(0:360), dtr, theta, dx, dy, r + real*8 x(0:360), y(0:360), dtr, theta, dx, dy, r, offset integer i, j, nsp integer PL_PARSE_FULL parameter(PL_PARSE_FULL = 1) @@ -69,12 +69,21 @@ C Write labels for angle text = text(nsp(text):) + + if (theta .lt. 9.99) then + offset = 0.45 + elseif (theta .lt. 99.9) then + offset = 0.30 + else + offset = 0.15 + endif + C Slightly off zero to avoid floating point logic flips at C 90 and 270 deg. if (dx.ge.-0.00001d0) then - call plptex(dx, dy, dx, dy, -0.15d0, text) + call plptex(dx, dy, dx, dy, -offset, text) else - call plptex(dx, dy, -dx, -dy, 1.15d0, text) + call plptex(dx, dy, -dx, -dy, (1.d0 + offset), text) end if enddo C Draw the graph Modified: trunk/examples/f95/x03f.f90 =================================================================== --- trunk/examples/f95/x03f.f90 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/f95/x03f.f90 2008-10-14 22:20:08 UTC (rev 8908) @@ -24,7 +24,7 @@ character*3 text real(kind=plflt) x0(0:360), y0(0:360) - real(kind=plflt) x(0:360), y(0:360), dtr, theta, dx, dy, r + real(kind=plflt) x(0:360), y(0:360), dtr, theta, dx, dy, r, offset integer i, j, nsp ! Process command-line arguments call plparseopts(PL_PARSE_FULL) @@ -66,12 +66,20 @@ ! Write labels for angle text = text(nsp(text):) + + if (theta .lt. 9.99) then + offset = 0.45 + elseif (theta .lt. 99.9) then + offset = 0.30 + else + offset = 0.15 + endif ! Slightly off zero to avoid floating point logic flips at ! 90 and 270 deg. if (dx.ge.-0.00001_plflt) then - call plptex(dx, dy, dx, dy, -0.15_plflt, text) + call plptex(dx, dy, dx, dy, -offset, text) else - call plptex(dx, dy, -dx, -dy, 1.15_plflt, text) + call plptex(dx, dy, -dx, -dy, 1._plflt+offset, text) end if enddo ! Draw the graph Modified: trunk/examples/java/x03.java =================================================================== --- trunk/examples/java/x03.java 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/java/x03.java 2008-10-14 22:20:08 UTC (rev 8908) @@ -47,7 +47,7 @@ NumberFormat nf = NumberFormat.getNumberInstance(); int i, j; - double dtr, theta, dx, dy, r; + double dtr, theta, dx, dy, r, offset; double[] x0 = new double[361]; double[] y0 = new double[361]; @@ -96,11 +96,19 @@ // Write labels for angle. + if (theta < 9.99) { + offset = 0.45; + } else if (theta < 99.9) { + offset = 0.30; + } else { + offset = 0.15; + } + //Slightly off zero to avoid floating point logic flips at 90 and 270 deg. if (dx >= -0.00001) - pls.ptex(dx, dy, dx, dy, -0.15, text); + pls.ptex(dx, dy, dx, dy, -offset, text); else - pls.ptex(dx, dy, -dx, -dy, 1.15, text); + pls.ptex(dx, dy, -dx, -dy, 1.+offset, text); } // Draw the graph. Modified: trunk/examples/ocaml/x03.ml =================================================================== --- trunk/examples/ocaml/x03.ml 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/ocaml/x03.ml 2008-10-14 22:20:08 UTC (rev 8908) @@ -62,12 +62,19 @@ (* Write labels for angle *) + (*if theta < 9.99 then + let offset = 0.45 in + else if theta < 99.9 then + let offset = 0.30 in + else *) + let offset = 0.15 in + (* Slightly off zero to avoid floating point logic flips at 90 and 270 deg.*) if dx >= -0.00001 then - plptex dx dy dx dy (-0.15) text + plptex dx dy dx dy (-.offset) text else - plptex dx dy (-.dx) (-.dy) 1.15 text + plptex dx dy (-.dx) (-.dy) (1.+.offset) text done; (* Draw the graph *) Modified: trunk/examples/perl/x03.pl =================================================================== --- trunk/examples/perl/x03.pl 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/perl/x03.pl 2008-10-14 22:20:08 UTC (rev 8908) @@ -65,13 +65,21 @@ pljoin (0, 0, $dx, $dy); + if ($theta < 9.99) { + $offset = 0.45; + } elsif ($theta < 99.9) { + $offset = 0.30; + } else { + $offset = 0.15; + } + # Write labels for angle # Slightly off zero to avoid floating point logic flips at 90 and 270 deg if ($dx >= -0.00001) { - plptex ($dx, $dy, $dx, $dy, -0.15, int ($theta)); + plptex ($dx, $dy, $dx, $dy, -$offset, int ($theta)); } else { - plptex ($dx, $dy, -$dx, -$dy, 1.15, int ($theta)); + plptex ($dx, $dy, -$dx, -$dy, (1.+$offset), int ($theta)); } } Modified: trunk/examples/python/xw03.py =================================================================== --- trunk/examples/python/xw03.py 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/python/xw03.py 2008-10-14 22:20:08 UTC (rev 8908) @@ -38,11 +38,17 @@ # Write labels for angle text = `int(theta)` + if theta < 9.99: + offset = 0.45 + elif theta < 99.9: + offset = 0.30 + else: + offset = 0.15 #Slightly off zero to avoid floating point logic flips at 90 and 270 deg. if dx >= -0.00001: - plptex(dx, dy, dx, dy, -0.15, text) + plptex(dx, dy, dx, dy, -offset, text) else: - plptex(dx, dy, -dx, -dy, 1.15, text) + plptex(dx, dy, -dx, -dy, 1.+offset, text) # Draw the graph Modified: trunk/examples/tcl/x03.tcl =================================================================== --- trunk/examples/tcl/x03.tcl 2008-10-14 20:59:13 UTC (rev 8907) +++ trunk/examples/tcl/x03.tcl 2008-10-14 22:20:08 UTC (rev 8908) @@ -39,15 +39,24 @@ set yg [expr sin($theta)] $w cmd pljoin 0.0 0.0 $xg $yg + set theta_deg [expr $theta*360./$twopi] + if {$theta_deg < 9.99} { + set offset 0.45 + } elseif {$theta_deg < 99.9} { + set offset 0.30 + } else { + set offset 0.15 + } + # Slightly off zero to avoid floating point logic flips at 90 and 270 deg. if {$xg >= -0.00001} { - set dx $xg - set dy $yg - set just -0.15 + set dx [expr $xg] + set dy [expr $yg] + set just [expr -$offset] } else { set dx [expr -$xg] set dy [expr -$yg] - set just 1.15 + set just [expr 1. + $offset] } set label [expr round($theta*360./$twopi)] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |