1; Work under GNU GPL 2; 3; Alain Coulais 4; Distributed version 2008/02/07 5; Initial version in June 2007 6; 7; Purpose: test suite for TITLE, SUBTITLE, XTITLE and YTITLE keywords 8; in PLOT and CONTOUR, showing positioning, math and greek options 9; 10; Demo for Embedded Formatting Commands 11; http://idlastro.gsfc.nasa.gov/idl_html_help/Embedded_Formatting_Commands.html 12; http://idlastro.gsfc.nasa.gov/idl_html_help/Formatting_Command_Examples.html 13;---------------------------------------------------------------------- 14; This function create a STRING containing "number" time the "character" 15; 16function AC_STRV, character, number 17; 18vector=character 19for ii=1, number-1 do vector=vector+character 20return, vector 21end 22 23 24pro title_scale, _extra=_extra 25tt=AC_STRV('f', 40) 26plot, findgen(10), titl=tt, xtit=tt, ytit=tt, subti=tt, _extra=_extra 27 28end 29 30; 31; complex title with greek and math... 32; 33pro titre1, full=full, ymargin=ymargin, charsize=charsize 34 35t1='!6F(s) = (2!4p)!e-1/2!n !mi!s!a!e!m' + STRING(36b) 36t1=t1+'!r!b!i-!m' + STRING(36b) + '!nF(x)e!e-i2!4p!3xs!ndx' 37 38if KEYWORD_SET(full) then t1b=t1 else t1b='' 39if N_ELEMENTS(ymargin) EQ 0 then ymargin=[3,5] 40if N_ELEMENTS(charsize) EQ 0 then charsize=2. 41 42plot, findgen(10), charsize=charsize, /nodata, ymargin=ymargin, $ 43 title=t1, xtitle=t1b, ytitle=t1b, subtitle=t1b 44 45xyouts, 0.2, 0.5, charsize=3, t1,/normal 46xyouts, 1, 2, charsize=2.2, t1,/data 47end 48 49 50pro titre2 51 52t2='!MI!S!A!E!8x!R!B!Ip!N !7q!Ii!N!8U!S!E2!R!Ii!Ndx' 53 54if KEYWORD_SET(full) then t2b=t2 else t2b='' 55 56plot, findgen(10),/nodata, ymargin=[3,5], charsize=2, title=t2, $ 57 xtitle=t2b, ytitle=t2b, subtitle=t2b 58 59XYOUTS, 0.5, .5, t2, $ 60 charSIZE = 8, /NORMAL 61end 62 63; 64; exemple basic de superposition 65; 66pro titre3 67 68t3='!S!3dessous!rDESSUS n!Son!rOUI' 69plot, findgen(10), charsize=3, ymargin=[5,8], title=t3 70end 71; 72; les differents indices ... 73; 74pro titre4 75 76t4='!3!n niveauref!LlL!n!DdD!n!IiI!n!AaA!n!BbB!n!EeE!n!UuU!UuU' 77plot, findgen(10), charsize=3, ymargin=[5,8], title=t4 78 79t4b='!3!n!scou!r!uca !n!scou!r!Lca' 80plot, findgen(10), charsize=3, ymargin=[5,8], title=t4b 81 82end 83 84; 85; testing and adjusting aligment 86; 87pro TITRE5, charsize=charsize 88; 89if N_ELEMENTS(charsize) NE 1 then charsize=2 90; 91title='aAa!iaiA!uaUA!n!iaA!nDD!dadDA!nttt!lalLA!naa' 92plot, ymargin=[3,6], findgen(10), title=title, charsize=charsize 93 94rep='' 95read, 'suite (rc)', rep 96; 97; testing the "sub" index capabilities 98; 99title='aAa!iaiA!uaUA!n!iaA!nDD!dadDA!nttt!lalLA!naa' 100title=title+'!eaa!ubb!ecc!n!daa!euu' 101plot, ymargin=[3,6], findgen(10), title=title, charsize=charsize 102 103rep='' 104read, 'suite (rc)', rep 105title='aAa!iaiA!uaUA!n!iaA!nDD!dadDA!nttt!lalLA!naa' 106plot, ymargin=[3,6], findgen(10), title=title, charsize=charsize 107 108end 109; 110; ---------------------------------------- 111; showing the effects of positioning commands (!U, !L, !M ...) 112; 113pro TITLE_FORMATING_EXAMPLE, postscript=postscript, title=title 114; 115if KEYWORD_SET(postscript) then begin 116 set_plot, 'ps' 117 device, filename='title_example.ps' 118endif 119; 120PcharRef=!p.charsize 121if (!p.charsize LT 1e-6) then begin 122 !p.charsize=2 123 print, 'You can play with !p.charsize to test other Char Sizes ...' 124endif 125; 126if (N_ELEMENTS(title) EQ 0) then begin 127 title='!3RefLevel' 128 title=title+'!LLower!S!EExponent!R!IIndex!N Normal' 129 title=title+'!S!EExp!R!IInd!N!S!U Up!R!D Down!N!S!A Above!R!B Below' 130endif 131; 132plot, findgen(10), title=title, $ 133 xtitle=title, ytitle=title, subtitle=title 134; 135; remember size= does not exist in GDL 136; 137XYOUTS, 1, 5, title 138; 139if KEYWORD_SET(postscript) then begin 140 device,/close 141 print, 'PostScript File "title_example.ps" generated' 142 set_plot, 'x' 143endif 144; 145!p.charsize=PcharRef 146; 147end 148; 149; ----------------------------------------------- 150; AC le 20/01/2008 151; we alway have to check the effect with !p.multi ... 152; 153pro TEST_TITLES_PMULTI, all_titles=all_titles, title=title, help=help 154; 155if KEYWORD_SET(help) then begin 156 print, 'pro TEST_TITLES_PMULTI, all_titles=all_titles, $' 157 print, ' title=title, help=help' 158 print, '' 159 print, 'Advices: we can used external parameters (!p.charsize ...)' 160 print, 'to play with other options' 161 return 162endif 163; 164device,/decomposed 165; 166if (N_ELEMENTS(title) EQ 0) then title='gaspQWERTYassdsfgagfafd' 167; 168xtitle='' 169ytitle='' 170subtitle='' 171if KEYWORD_SET(all_titles) then begin 172 xtitle=title 173 ytitle=title 174 subtitle=title 175endif 176; 177window, 0 178!p.multi=0 179plot, findgen(10), title=title, subtitle=subtitle, xtitle=xtitle, ytitle=ytitle 180oplot, 10-findgen(10), color='ff'x 181; 182window, 1 183!p.multi=[0,2,2] 184plot, findgen(10), title=title, subtitle=subtitle, xtitle=xtitle, ytitle=ytitle 185oplot, 10-findgen(10), color='ff'x 186 187plot, findgen(10), title=title, subtitle=subtitle, xtitle=xtitle, ytitle=ytitle 188oplot, 10-findgen(10), color='ff00'x 189 190!p.multi=0 191 192end 193; 194; --------------------------------- 195; calling hub 196; 197pro TEST_TITLES, all=all 198; 199s='' 200TITLE_FORMATING_EXAMPLE 201READ, 'Please type any key to continue', s 202; 203TEST_TITLES_PMULTI, /all 204READ, 'Please type any key to continue', s 205; 206TITRE1 207READ, 'Please type any key to continue', s 208; 209if NOT(keyword_set(all)) then begin 210 print, 'To go further, you have to run individually the examples' 211 print, 'or to call them via /all keyword' 212 return 213endif 214; 215TITRE2 216READ, 'Please type any key to continue', s 217; 218TITRE3 219READ, 'Please type any key to continue', s 220; 221TITRE4 222READ, 'Please type any key to continue', s 223; 224TITRE5 225READ, 'Please type any key to continue', s 226; 227end 228 229