(bind-func draw_barplot
(let ((nlabs 5)
(labs:float* (zalloc nlabs))
(bars:float* (zalloc nlabs))
(line:float* (zalloc (* 2 nlabs)))
(i 0))
(dotimes (i nlabs)
(pset! labs i (* (convert i) (/ 1. (convert (- nlabs 1)))))
;; x positions should be in the middle of the bars
(pset! line (* i 2) (+ (/ .5 (convert nlabs)) (* (convert i) (/ 1. (convert nlabs))))))
(lambda (bounds:Rect*)
(dotimes (i nlabs)
(pset! bars i (+ .5 (* .3 (cos (* 0.00001 (convert (* (now) (+ i 1))))))))
(pset! line (+ (* i 2) 1) (+ .5 (* .3 (cos (* 0.00001 (convert (* (now) (+ i 1)))))))))
(dv_draw_bars vg bounds bars nlabs)
(dv_draw_axis_labels_2D vg bounds labs nlabs labs nlabs)
(dv_draw_axes_2D vg bounds)
(dv_draw_title vg bounds "Barplot")
(dv_draw_line vg bounds line nlabs)
void)))