if .not.do_header return
!
on error
gtvl\change directory <greg
gtvl\create directory hbox
gtvl\change directory hbox
define real dz x2 y2
define char place*8
!
! Defined in p_header  -- Should be factorized
greg1\set box xbox xbox+boxs ybox ybox+boxs
!
let x2 box_xmax
let y2 box_ymax
!
greg1\set expand 0.6
if (page_x.gt.page_y) then
  let dz min((page_x-x2)|aspect,0.5*page_y)
  ! Shifted in X, Centered around 0.35 in Y
  greg1\set box page_x-0.4-0.6*dz*aspect page_x-0.4  0.35*page_y-0.3*dz 0.35*page_y+0.3*dz
  let place "top"
else
  let dz min((0.5*page_x|aspect),(page_y-y2))
  ! Right adjusted in X, Centered around in Y
  greg1\set box page_x-2.0-0.6*dz*aspect page_x-2.0 (page_y+y2-0.6*dz)*0.5 (page_y+y2+0.6*dz)*0.5
  let place "right"
endif
@ p_box  legend &1
!
if do_wedge then
  if (spacing.eq.-1) then
    greg2\wedge 'place' /scaling linear true_scale[1] true_scale[2] /level
  else
    greg2\wedge 'place' /scaling linear true_scale[1] true_scale[2]
  endif
endif
gtvl\change directory <greg
greg1\set expand 1.0
