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

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Tue Jul 29 15:02:37 EDT 2014

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)))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: with-error.pdf
Type: application/pdf
Size: 39014 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20140729/a561aec8/attachment-0002.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: without-error.pdf
Type: application/pdf
Size: 36857 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20140729/a561aec8/attachment-0003.pdf>

Posted on the users mailing list.