[racket] Plot question: discrete-histogram with error-bars
I don't see anything that addresses the number/category mismatch in the benchmark library. I just hacked on error-bars to take the same keywords that discrete-histogram takes for introducing ticks, #:add-ticks? and #:far-ticks?, and use those for something like default-ticks-fun in plot-element, only returns empty for x,y[,z] if the given booleans are false.
-Ian
----- Original Message -----
From: "Vincent St-Amour" <stamourv at ccs.neu.edu>
To: "J. Ian Johnson" <ianj at ccs.neu.edu>
Cc: "users" <users at racket-lang.org>
Sent: Tuesday, July 29, 2014 3:17:03 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket] Plot question: discrete-histogram with error-bars
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: error.patch
Type: text/x-patch
Size: 4002 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20140729/213e55ca/attachment.bin>