Example of how to set up a horizontal time axis on a BLT graph labelled both with dates and intermediate hour markers, and with the dates centralized with respect to the hours. Execute in wish, and it should look like this: [http://www.crossrad.uklinux.net/blt_pdw_190602.jpg]. The ideas used here are: * Create custom tick labels with easy to read time formats using "clock scan" and "clock format". * The custom tick labels may contain \n to create multi-line labels. * Labels may be centralized between ticks by shifting them to the right with spaces. * The number of spaces may be calculated by using the BLT "axis transform" method to get the distance between the ticks in pixels, and using "font measure" to convert this to a number of spaces. * This should work with all fonts, because the actual font used is queried with "axis cget" and passed to "font measure". Version D - Paul Welton - 20.06.02 package require BLT pack [blt::graph .g -width 10i] # Proc passed as a callback to BLT to draw custom tick labels. # proc format_timeAxis_tick {win seconds} { set hour [clock format $seconds -format "%H"] regsub {^0*} $hour {} label if {$hour} { return $label } else { return "$label\n[string repeat { } $::nSpaces]\ [clock format $seconds -format "%d/%m"]" } } # Construct a list of major tick positions in seconds - the # month, year and the range of days can be varied to suit # the application. # for {set day 20} {$day <= 23} {incr day} { foreach hours {0 4 8 12 16 20} { lappend majorticks [clock scan "3/$day/2001 $hours:00"] } } lappend majorticks [clock scan "3/$day/2001 00:00"] # Create the graph. .g axis configure x \ -min [lindex $majorticks 0] \ -max [lindex $majorticks end] \ -title "Day" \ -majorticks $majorticks # Need to do an update to display the graph before the # distance can be measured. update # Measure the width of a day on the graph - the example # dates need not be in the displayed range. set dayFieldWidth [expr { [.g axis transform x [clock scan 3/2/2001]] - [.g axis transform x [clock scan 3/1/2001]]}] # Work out how many spaces this corresponds to in the # font for the tick labels. set nSpaces [expr {$dayFieldWidth / [font measure [.g axis cget x -tickfont] " "]}] # Configure the axis to use the custom label command. .g axis configure x -command format_timeAxis_tick