EPS: preakness.eps

Script: make-preakness.tcl


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

# define the canvas
PsCanvas -title "preakness.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 "preakness.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 108
set ymax 126

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


# 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
}

set mean [TableComputeAvg -column time]
# puts "Mean running time is $mean"
Line -coord $xmin,$mean:$xmax,$mean -linewidth 0.5 -linedash 2,2
# Box -coord 1926,[expr $mean-$stddev]:2007,[expr $mean+$stddev] -linewidth 0 -fill t -fillcolor lightgrey

# 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 "Preakness Stakes" -yauto $ymin,$ymax,2 -xauto 1930,2000,10

# plot the horses running times
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 "preakness.eps"



Data: preakness.txt.out