EPS: derby.eps

Script: make-derby.tcl

# source the library
source zplot.tcl; namespace import Zplot::*

# define the canvas
PsCanvas -title "derby.eps" -width 8.5in -height 3.5in

set c(runavg) forestgreen
set c(best) orange

# read in the file into a table called bar1
Table -file "derby.txt.out" -separator ":"
TableAddColumns -columns zero -value 0
TableSort -column year -integer true

# get last value from table, add something to it
set maxyear [TableGetMax -column year]

# this defines one particular drawing area
set ymin 114
set ymax 132

set xmin 1925
set xmax 2010

Drawable -xrange $xmin,$xmax -yrange $ymin,$ymax -coord 40,40
Drawable -drawable d2 -xrange $xmin,$xmax -yrange 0,1 -coord 40,40

set mean [TableComputeAvg -column time]
# Box -coord 1926,[expr $mean-$stddev]:2007,[expr $mean+$stddev] -linewidth 0 -fill t -fillcolor lightgrey

# make colored backgrounds
for {set y $xmin} {$y <= $xmax} {incr y 2} {
Box -coord $y,$ymin:[expr $y+1],$ymax -linewidth 0 -fill t -fillcolor lavender

# should calculate this!
Line -coord $xmin,$mean:$xmax,$mean -linewidth 0.5 -linedash 2,2

# labels
# Label -coord 1935.5,[expr $mean-3] -text "Overall Average ($mean +/- [format %.2f $stddev])" -fontsize 7 -anchor l,c
# Line -coord 1935,[expr $mean-3]:1930,[expr $mean-0.6] -arrow t -linewidth 0.5

# Label -coord 1946.5,154 -text "Running Average" -fontsize 7 -anchor l,c -color $c(runavg)
# Line -coord 1946,154:1938,152 -arrow t -linewidth 0.5 -linecolor $c(runavg) -arrowfillcolor $c(runavg) -arrowlinecolor $c(runavg)

AxesTicsLabels -xtitle "Year" -ytitle "Time (Seconds)" -title "Kentucky Derby" -yauto $ymin,$ymax,2 -xauto 1930,2000,10

PlotLines -xfield year -yfield time -linecolor black -linewidth 0.5 -stairstep true

TableMath -destcol year -expression {$year + 0.5}
PlotLines -drawable d2 -xfield year -yfield zero -labelfield horse -labelrotate 90 -labelsize 6 -labelanchor l,c
PlotLines -xfield year -yfield runavg -linewidth 0.5 -linecolor $c(runavg)
# Line -coord 2007,148.74:2008,148.74 -linewidth 0.5

# Line -coord 1976.5,144:1975,144 -arrow t -linewidth 0.5 -arrowfillcolor $c(best) -arrowfill $c(best) -linecolor $c(best) -arrowlinecolor $c(best)
# Label -coord 1977,144 -text "Why we remember Secretariat" -anchor l,c -color $c(best) -fontsize 7
# Label -drawable d2 -coord 1973.5,0 -anchor l,c -rotate 90 -text "Secretariat" -fontsize 6 -color $c(best) -shift 0,3 -bgcolor lavender

PsRender -file "derby.eps"

Data: derby.txt.out