From: <arj...@us...> - 2011-02-04 09:57:55
|
Revision: 11545 http://plplot.svn.sourceforge.net/plplot/?rev=11545&view=rev Author: arjenmarkus Date: 2011-02-04 09:57:49 +0000 (Fri, 04 Feb 2011) Log Message: ----------- Updated examples for Fortran 77 and Fortran 95. Example 33 still needs work (differences in colours). API for Fortran 95 requires some additional work, but it does do the job. Modified Paths: -------------- trunk/examples/f77/x04f.fm4 trunk/examples/f77/x26f.fm4 trunk/examples/f77/x33f.fm4 trunk/examples/f95/x04f.f90 trunk/examples/f95/x26f.f90 Modified: trunk/examples/f77/x04f.fm4 =================================================================== --- trunk/examples/f77/x04f.fm4 2011-02-03 08:19:52 UTC (rev 11544) +++ trunk/examples/f77/x04f.fm4 2011-02-04 09:57:49 UTC (rev 11545) @@ -44,8 +44,8 @@ & line_styles(2), line_widths(2), symbol_colors(2), & symbol_numbers(2) real*8 symbol_scales(2) - integer box_colors(1), box_patterns(1), box_scales(1) - real*8 box_line_widths(1) + integer box_colors(1), box_patterns(1), box_line_widths(1) + real*8 box_scales(1) character*20 text(2) character*1 symbols(2) Modified: trunk/examples/f77/x26f.fm4 =================================================================== --- trunk/examples/f77/x26f.fm4 2011-02-03 08:19:52 UTC (rev 11544) +++ trunk/examples/f77/x26f.fm4 2011-02-04 09:57:49 UTC (rev 11545) @@ -164,8 +164,8 @@ integer symbol_colors(local_nlegend) real*8 symbol_scales(local_nlegend) character*20 symbols(local_nlegend) - integer box_colors(1), box_patterns(1), box_scales(1) - real*8 box_line_widths(1) + integer box_colors(1), box_patterns(1), box_line_widths(1) + real*8 box_scales(1) real*8 legend_width, legend_height c Sanity check. Modified: trunk/examples/f77/x33f.fm4 =================================================================== --- trunk/examples/f77/x33f.fm4 2011-02-03 08:19:52 UTC (rev 11544) +++ trunk/examples/f77/x33f.fm4 2011-02-04 09:57:49 UTC (rev 11545) @@ -156,10 +156,10 @@ do 110 k = 1,16 position = position_options(k) opt = opt_base - text_colors(1) = 1 + mod( k, 8 ) - line_colors(1) = 1 + mod( k, 8 ) - symbol_colors(1) = 1 + mod( k, 8 ) - call write_number( text(1), k ) + text_colors(1) = 1 + mod( k-1, 8 ) + line_colors(1) = 1 + mod( k-1, 8 ) + symbol_colors(1) = 1 + mod( k-1, 8 ) + call write_number( text(1), k-1 ) call pllegend( legend_width, legend_height, position, opt, & 0.05d0, 0.05d0, @@ -197,10 +197,10 @@ symbol_scales(k) = 1.d0 symbol_numbers(k) = 2 symbols(k) = '*' - call write_number( text(k), k ) - text_colors(k) = 1 + mod( k, 8 ) - line_colors(k) = 1 + mod( k, 8 ) - symbol_colors(k) = 1 + mod( k, 8 ) + call write_number( text(k), k-1 ) + text_colors(k) = 1 + mod( k-1, 8 ) + line_colors(k) = 1 + mod( k-1, 8 ) + symbol_colors(k) = 1 + mod( k-1, 8 ) 120 continue c Use monotype fonts so that all legends are the same size. @@ -294,10 +294,6 @@ & line_colors, line_styles, line_widths, & symbol_colors, symbol_scales, symbol_numbers, symbols ) -c -c This causes an access violation? -c - position = PL_POSITION_BOTTOM + PL_POSITION_INSIDE opt = opt_base + PL_LEGEND_ROW_MAJOR x = 0.d0 @@ -349,10 +345,10 @@ symbol_scales(k) = 1.d0 symbol_numbers(k) = 2 symbols(k) = '*' - call write_number( text(k), k ) - text_colors(k) = 1 + mod( k, 8 ) - line_colors(k) = 1 + mod( k, 8 ) - symbol_colors(k) = 1 + mod( k, 8 ) + call write_number( text(k), k-1 ) + text_colors(k) = 1 + mod( k-1, 8 ) + line_colors(k) = 1 + mod( k-1, 8 ) + symbol_colors(k) = 1 + mod( k-1, 8 ) 130 continue c Use monotype fonts so that all legends are the same size. @@ -465,8 +461,8 @@ do 150 i = 1,nlegend opt_array(i) = PL_LEGEND_SYMBOL text(i) = 'Symbol ' // special_symbols(i) - text_colors(i) = i + 1 - symbol_colors(i) = i + 1 + text_colors(i) = i + symbol_colors(i) = i symbol_scales(i) = text_scale symbol_numbers(i) = 4 symbols(i) = special_symbols(i) @@ -490,8 +486,8 @@ do 160 i = 1,nlegend opt_array(i) = PL_LEGEND_SYMBOL call write_text_number( text(i), 'Symbol Number', i + 1 ) - text_colors(i) = i + 1 - symbol_colors(i) = i + 1 + text_colors(i) = i + symbol_colors(i) = i symbol_scales(i) = text_scale symbol_numbers(i) = i + 2 symbols(i) = special_symbols(3) @@ -544,7 +540,7 @@ do 180 i = 1,nlegend opt_array(i) = PL_LEGEND_COLOR_BOX - call write_text_number( text(i), 'Box Pattern', i ) + call write_text_number( text(i), 'Box Pattern', i-1 ) text_colors(i) = 2 box_colors(i) = 2 box_patterns(i) = i - 1 @@ -626,7 +622,7 @@ call write_text_number( text(i), 'Line Style', i ) text_colors(i) = 2 line_colors(i) = 2 - line_styles(i) = i + 1 + line_styles(i) = i line_widths(i) = 1 210 continue @@ -651,7 +647,7 @@ text_colors(i) = 2 line_colors(i) = 2 line_styles(i) = 1 - line_widths(i) = i + 1 + line_widths(i) = i 220 continue opt = opt_base Modified: trunk/examples/f95/x04f.f90 =================================================================== --- trunk/examples/f95/x04f.f90 2011-02-03 08:19:52 UTC (rev 11544) +++ trunk/examples/f95/x04f.f90 2011-02-04 09:57:49 UTC (rev 11545) @@ -73,7 +73,7 @@ ! Plot ampl vs freq. call plcol0(2) call plline(freql,ampl) - call plcol0(1) + call plcol0(2) call plptex(1.6_plflt, -30.0_plflt, 1.0_plflt, -20.0_plflt, 0.5_plflt, & '-20 dB/decade') ! Put labels on. Modified: trunk/examples/f95/x26f.f90 =================================================================== --- trunk/examples/f95/x26f.f90 2011-02-03 08:19:52 UTC (rev 11544) +++ trunk/examples/f95/x26f.f90 2011-02-04 09:57:49 UTC (rev 11545) @@ -1,6 +1,6 @@ ! -*- coding: utf-8; -*- ! -! $Id:$ +! $Id$ ! ! Multi-lingual version of the first page of example 4. ! @@ -74,16 +74,17 @@ use plplot, PI => PL_PI implicit none - integer nolangs - parameter ( nolangs = 2 ) + integer, parameter :: nolangs = 2 + integer, parameter :: nlegend = 2 character*80 x_label(nolangs) character*80 y_label(nolangs) + character*80 legend_text(2,nolangs) character*80 alty_label(nolangs) character*80 title_label(nolangs) character*80 line_label(nolangs) - integer i + integer i, j data (x_label(i) ,i=1,nolangs) / & 'Frequency', & @@ -97,6 +98,11 @@ 'Phase shift (degrees)', & 'Фазовый сдвиг (градусы)'/ + ! Short rearranged versions of y_label and alty_label. + data ((legend_text(j,i), j=1, nlegend), i=1,nolangs) / & + 'Amplitude', 'Phase shift' , & + 'Амплитуда', 'Фазовый сдвиг' / + data (title_label(i) ,i=1,nolangs) / & 'Single Pole Low-Pass Filter', & 'Однополюсный Низко-Частотный Фильтр'/ @@ -117,8 +123,8 @@ ! Make log plots using two different styles. do i = 1,nolangs - call plot1(0, x_label(i), y_label(i), alty_label(i), & - title_label(i), line_label(i)) + call plot1(nlegend, 0, x_label(i), y_label(i), alty_label(i), & + legend_text(:,i), title_label(i), line_label(i)) end do call plend() @@ -130,19 +136,34 @@ ! Log-linear plot. ! -------------------------------------------------------------------------- - subroutine plot1( type, x_label, y_label, alty_label, & - title_label, line_label ) + subroutine plot1( nlegend, type, x_label, y_label, alty_label, & + legend_text, title_label, line_label ) use plplot, PI => PL_PI implicit none - integer type + integer type, nlegend character(*) x_label, y_label, alty_label, title_label, line_label integer i real(kind=plflt) freql(101), ampl(101), phase(101) real(kind=plflt) f0, freq + character(*) legend_text(nlegend) + + integer opt_array(nlegend) + integer text_colors(nlegend) + integer line_colors(nlegend) + integer line_styles(nlegend) + integer line_widths(nlegend) + integer symbol_numbers(nlegend) + integer symbol_colors(nlegend) + real(kind=plflt) symbol_scales(nlegend) + character*20 symbols(nlegend) + integer box_colors(0), box_patterns(0), box_line_widths(0) + real(kind=plflt) box_scales(0) + real(kind=plflt) legend_width, legend_height + call pladv(0) ! Set up data for log plot @@ -156,9 +177,9 @@ end do call plvpor(0.15_plflt, 0.85_plflt, 0.1_plflt, 0.9_plflt) call plwind(-2.0_plflt, 3.0_plflt, -80.0_plflt, 0.0_plflt) - + ! Try different axis and labelling styles. - + call plcol0(1) if ( type .eq. 0 ) then call plbox("bclnst", 0.0_plflt, 0, "bnstv", 0.0_plflt, 0) @@ -166,31 +187,77 @@ if ( type .eq. 1 ) then call plbox("bcfghlnst", 0.0_plflt, 0, "bcghnstv", 0.0_plflt, 0) endif - + ! Plot ampl vs freq - + call plcol0(2) call plline(freql, ampl) - call plcol0(1) + call plcol0(2) call plptex(1.6_plflt, -30.0_plflt, 1.0_plflt, -20.0_plflt, 0.5_plflt, line_label) ! Put labels on - + call plcol0(1) call plmtex("b", 3.2_plflt, 0.5_plflt, 0.5_plflt, x_label) call plmtex("t", 2.0_plflt, 0.5_plflt, 0.5_plflt, title_label) call plcol0(2) call plmtex("l", 5.0_plflt, 0.5_plflt, 0.5_plflt, y_label) - + ! For the gridless case, put phase vs freq on same plot - + if (type .eq. 0) then call plcol0(1) call plwind(-2.0_plflt, 3.0_plflt, -100.0_plflt, 0.0_plflt) call plbox("", 0.0_plflt, 0, "cmstv", 30.0_plflt, 3) call plcol0(3) call plline(freql, phase) + call plstring(freql, phase, '*') call plcol0(3) call plmtex("r", 5.0_plflt, 0.5_plflt, 0.5_plflt, alty_label) endif + + ! Draw a legend + ! First legend entry. + + opt_array(1) = PL_LEGEND_LINE + text_colors(1) = 2 + line_colors(1) = 2 + line_styles(1) = 1 + line_widths(1) = 1 + ! defining this makes the Fortran to C transformation of + ! symbols(1) work on defined values which makes valgrind + ! happier (even if that transformed string is not used inside the + ! C version of pllegend) + symbols(1) = "" + + ! note from the above opt_array the first symbol (and box) indices + ! do not have to be specified + + ! Second legend entry. + + opt_array(2) = PL_LEGEND_LINE + PL_LEGEND_SYMBOL + text_colors(2) = 3 + line_colors(2) = 3 + line_styles(2) = 1 + line_widths(2) = 1 + symbol_colors(2) = 3 + symbol_scales(2) = 1. + symbol_numbers(2) = 4 + symbols(2) = "*" + + ! from the above opt_arrays we can completely ignore everything + ! to do with boxes. + + call plscol0a( 15, 32, 32, 32, 0.70d0 ) + call pllegend( legend_width, legend_height, & + 0, PL_LEGEND_BACKGROUND + PL_LEGEND_BOUNDING_BOX, & + 0.0_plflt, 0.0_plflt, 0.10_plflt, 15, & + 1, 1, 0, 0, & + nlegend, opt_array, & + 1.0_plflt, 1.0_plflt, 2.0_plflt, & + 1.0_plflt, text_colors, legend_text, & + box_colors, box_patterns, box_scales, box_line_widths, & + line_colors, line_styles, line_widths, & + symbol_colors, symbol_scales, symbol_numbers, symbols ) + end subroutine plot1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |