+struct box
+ {
+ struct box_whisker *bw;
+ char *label;
+ };
+
+struct boxplot
+ {
+ struct chart chart;
+ double y_min;
+ double y_max;
+ char *title;
+ struct box *boxes;
+ size_t n_boxes, boxes_allocated;
+ };
+
+static const struct chart_class boxplot_chart_class;
+
+struct boxplot *
+boxplot_create (double y_min, double y_max, const char *title)
+{
+ struct boxplot *boxplot = xmalloc (sizeof *boxplot);
+ chart_init (&boxplot->chart, &boxplot_chart_class);
+ boxplot->y_min = y_min;
+ boxplot->y_max = y_max;
+ boxplot->title = xstrdup (title);
+ boxplot->boxes = NULL;
+ boxplot->n_boxes = boxplot->boxes_allocated = 0;
+ return boxplot;
+}
+
+void
+boxplot_add_box (struct boxplot *boxplot,
+ struct box_whisker *bw, const char *label)
+{
+ struct box *box;
+ if (boxplot->n_boxes >= boxplot->boxes_allocated)
+ boxplot->boxes = x2nrealloc (boxplot->boxes, &boxplot->boxes_allocated,
+ sizeof *boxplot->boxes);
+ box = &boxplot->boxes[boxplot->n_boxes++];
+ box->bw = bw;
+ box->label = xstrdup (label);
+}
+
+struct chart *
+boxplot_get_chart (struct boxplot *boxplot)
+{
+ return &boxplot->chart;
+}
+