[racket] Plot question: discrete-histogram with error-bars

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Tue Jul 29 15:17:03 EDT 2014

Have a look at the benchmarking library. I remember we solved that
problem, but I don't remember how off the top of my head.

Vincent


At Tue, 29 Jul 2014 15:02:37 -0400 (EDT),
J. Ian Johnson wrote:
> 
> error-bars does not work with discrete-histogram in a convenient way. I've mostly worked around it by computing the x coordinate for where each error bar will go, but providing a number instead of the histogram's "category" introduces a new axis that gets rendered with my histogram's categories. It doesn't really make sense to show those numbers.
> 
> As a stopgap measure before error-bars (or discrete-histogram) is fixed, how do I tell plot to not render the error-bar's x axis?
> 
> I've attached what a plot looks like with and without error bars to illustrate the problematic output.
> Thanks,
> -Ian
> 
> (resent with compressed attachments)
> 
> Here is a snippet of the rendering code I'm using.
> (define (get-numbers tag sel)
>   (define (scale x) (if (number? x) x 0))
>   (for*/list ([(name numbers) (in-hash timings)]
>               [n (in-value (hash-ref numbers tag))])
>     (list name
>             (scale (average-vec (sel n)))
>             (scale (stddev-vec (sel n))))))
> 
> (define (bench-plot sel y-label x-label out-file)
>   (plot
>    (for/fold ([plots '()])
>         ([(tag algo) (in-dict algo-name)]
>          [i (in-naturals)])
>       (define numbers* (get-numbers tag sel))
>       (define skip 5.5)
>       (define error
>         ;; For current algo, give error bars for each benchmark.
>         (error-bars (for/list ([x numbers*] [m (in-naturals)])
>                      (list (+ 1/2 i (* m skip))
>                            (second x)
>                            (third x)))
>                    #:x-min i
>                    #:color -7))
>      (list* error
>             (discrete-histogram (for/list ([x numbers*]) (list (first x) (second x)))
>                                 #:label algo
>                                 #:skip skip #:x-min i
>                                 #:style (add1 (* 2 i))
>                                 #:color -7 #:line-color "black"
>                                 #:line-style i)
>             plots))
>    #:y-label y-label
>    #:x-label x-label
>    #:legend-anchor 'top-left
>    #:out-file out-file))
> 
> (define (do-with-params thunk)
>   (parameterize ([plot-font-size 20]
>                  [plot-x-tick-label-anchor 'top-right]
>                  [plot-x-tick-label-angle 60]
>                  [line-color  "black"]
>                  [interval-color  "black"]
>                  [interval-line1-color  "black"]
>                  [interval-line2-color  "black"]
>                  [plot-width (* 2 (plot-width))])
>   (thunk)))
> [2 with-error.pdf <application/pdf (base64)>]
> 
> [3 without-error.pdf <application/pdf (base64)>]
> 
> [4  <text/plain; us-ascii (7bit)>]
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.