Menu

#1368 stripchart can't extend with custom labels

closed-fixed
5
2013-05-25
2013-05-22
No

If I create a stripchart with custom labels:

set s [Plotchart::createStripchart .c {0 10 ""} {0 10 1} -xlabels {a b c}]

I then get an error when I try to plot the final point in this data:

foreach {x y} {0 0 2 5 5 2 9 9 12 10} {
$s plot a $x $y
}

The issue appears to be that the tick interval is an empty string, which is necessary to get the custom x-axis labels to display. (I ran across this issue when providing user support in http://stackoverflow.com/q/16658143/301832 when changing from an xyplot to a stripchart.)

Discussion

  • Arjen Markus

    Arjen Markus - 2013-05-23

    As Donal informed me, the original purpose was to display a stripchart with time (or date/time) instead of numbers along the x-axis.
    Given that non-numeric custom labels are drawn at regular spacing, defined
    by their number, the concept is not a good match with stripcharts: stripcharts
    need to add new labels when the x-value increases beyond the upper limit.

    The solution I will implement is:
    - Give a proper error message about custom labels with stripcharts
    - Implement an option -timeformat (and an option -gmt) so that the x-axis
    gets labelled with dates/times instead of numbers.
    That option will allow generating new labels, just as with ordinary numbers.
    The option -gmt is meant to control daylight saving time surprises

     
  • Arjen Markus

    Arjen Markus - 2013-05-25

    Fixed as of version 2.1.1:
    Use the -timeformat option to display date/time labels in a stripchart.
    See the example below for the use of these options or the documentation:

    package require Plotchart
    pack [canvas .c]

    #
    # New code:
    # Note that we need to present the x values as clock seconds
    # The increment is equal to 2 hours (2*3600 seconds)
    #
    set start [clock scan "0:00"]
    set stop [clock scan "10:00"]
    set s [Plotchart::createStripchart .c [list $start $stop 7200] {0 10 1} -timeformat "%H:%M"]

    foreach {x y} {0 0 2 5 5 2 9 9 12 10} {
    set x [expr {$start + 3600 * $x}] ;# Convert hour to clock seconds
    $s plot a $x $y
    }

     
  • Arjen Markus

    Arjen Markus - 2013-05-25
    • status: open --> closed-fixed