# ex_hlines.ppl
#
# The code in this file is part of Pyxplot
# <http://www.pyxplot.org.uk>
#
# Copyright (C) 2006-2012 Dominic Ford <coders@pyxplot.org.uk>
#               2008-2012 Ross Church
#
# $Id: ex_hlines.ppl 1261 2012-07-11 21:38:05Z dcf21 $
#
# Pyxplot is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# You should have received a copy of the GNU General Public License along with
# Pyxplot; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA  02110-1301, USA

# ----------------------------------------------------------------------------

# This script produces a figure for the Pyxplot Users' Guide

# Call common initialisation script
reset
title = "ex_hlines"
load "examples/fig_init.ppl"
set terminal landscape

# BEGIN
set numeric display latex
set width 20
set size ratio 0.4
set numerics sf 4
set log x
set x1label "Wavelength"
set x2label "Frequency"     ; set unit of frequency Hz
set x3label "Photon Energy" ; set unit of energy eV
set axis x2 linked x1 using phy.c/x
set axis x3 linked x2 using phy.h*x
set noytics ; set nomytics

# Draw lines of first four series of hydrogen lines
an=2
n=1
foreach SeriesName in ["Ly","Ba","Pa","Br"]
 {
  for m=n+1 to n+21
   {
    wl = 1/(phy.Ry*(1/n**2-1/m**2))
    set arrow an from wl,0.3 to wl,0.6 with nohead col n
    if (m-n==1) { ; GreekLetter = r"\alpha" ; }
    if (m-n==2) { ; GreekLetter = r"\beta"  ; }
    if (m-n==3) { ; GreekLetter = r"\gamma" ; }
    if (m-n<4)
     {
      set label an r"\parbox{5cm}{\footnotesize\center{\
        %s-$%s$\newline $%d\to%d$\newline %s\newline}}" \
        %(SeriesName,GreekLetter,m,n,wl) at wl,0.55+0.2*(m-n) \
        hal center val center
     }
    an = an+1
   }
  n=n+1
 }

# Label astronomical photometric colors
foreach datum i,name,wl_c,wl_w in "--" using \
    1:"%s"%($2):($3*unit(nm)):($4*unit(nm))
 {
  arry = 0.12+0.1*(i%2) # Vertical positions for arrows
  laby = 0.07+0.1*(i%2) # Vertical positions for labels
  x0 = (wl_c-wl_w/2) # Shortward end of passband
  x1 =  wl_c         # Centre of passband
  x2 = (wl_c+wl_w/2) # Longward end of passband
  set arrow an from x0,arry to x2,arry with nohead
  set label an name at x1,laby hal center val center
  an = an+1
 }
 1 U  365   66
 2 B  445   94
 3 V  551   88
 4 R  658  138
 5 I  806  149
 6 J 1220  213
 7 H 1630  307
 8 K 2190  390
 9 L 3450  472
10 M 4750  460
END

# Draw a marker for the Lyman limit
ll = 91.1267*unit(nm)
set arrow 1 from ll,0.12 to ll,0.22
set label 1 "Lyman Limit: %s"%(ll) at 95*unit(nm),0.17 \
     hal left val center

# Finally produce plot
plot [80*unit(nm):5500*unit(nm)][0:1.25]
# END

# Call common cleanup script
load "examples/fig_end.ppl"

