|
From: Jouke W. <j.w...@gm...> - 2015-01-03 11:39:23
|
The x-value of individual boxplots is ignored when placing tics for
multiple boxplots.
This patch fixes that issue. It requires the previous patch, which
introduces default factor identifiers. With this patch in place, there
is a case for changing the default separation value for the boxplot
style to 0.
---
diff -Naur gnuplot-5.0.0.orig/src/plot2d.c gnuplot-5.0.0/src/plot2d.c
--- gnuplot-5.0.0.orig/src/plot2d.c 2015-01-03 01:34:55.149743745 +0100
+++ gnuplot-5.0.0/src/plot2d.c 2015-01-03 01:34:10.374844052 +0100
@@ -73,7 +73,7 @@
static void boxplot_range_fiddling __PROTO((struct curve_points *plot));
static void histogram_range_fiddling __PROTO((struct curve_points *plot));
static void impulse_range_fiddling __PROTO((struct curve_points *plot));
-static int check_or_add_boxplot_factor __PROTO((struct curve_points *plot, char* string, double x));
+static int check_or_add_boxplot_factor __PROTO((struct curve_points *plot, char* string, struct coordinate *cp));
static void add_tics_boxplot_factors __PROTO((struct curve_points *plot));
static void sort_boxplot_factors __PROTO((struct curve_points *plot));
static int compare_boxplot_factors __PROTO((SORTFUNC_ARGS arg1, SORTFUNC_ARGS arg2));
@@ -1085,9 +1085,13 @@
case BOXPLOT: /* x, y, width, factor */
/* Load the coords just as we would have for 3-argument boxplot,
* index of factor in ylow , yhigh is the same as y */
- store2d_point(current_plot, i++, v[0], v[1], v[0]-v[2]/2., v[0]+v[2]/2.,
- check_or_add_boxplot_factor(current_plot, df_tokens[3], v[0]),
- v[1], v[2]);
+ store2d_point(current_plot, i, v[0], v[1], v[0]-v[2]/2., v[0]+v[2]/2.,
+ DEFAULT_BOXPLOT_FACTOR, v[1], v[2]);
+ if (current_plot->points[i].type != UNDEFINED)
+ current_plot->points[i].ylow = check_or_add_boxplot_factor(
+ current_plot, df_tokens[3],
+ &(current_plot->points[i]));
+ i++;
break;
@@ -1506,7 +1510,7 @@
/* Check if <string> is already among the known factors, if not, add it to the list */
static int
-check_or_add_boxplot_factor(struct curve_points *plot, char* string, double x)
+check_or_add_boxplot_factor(struct curve_points *plot, char* string, struct coordinate *cp)
{
int len;
char * trimmed_string;
@@ -1527,10 +1531,14 @@
break;
}
- /* not found, so we add it now */
- if (!label)
- label = store_label(plot->labels, &(plot->points[0]),
- plot->boxplot_factors++, trimmed_string, 0.0);
+ if (label) {
+ /* for consistency, we store the position corresponding to the smallest y */
+ if (cp->y < label->place.y) {
+ label->place.x = cp->x;
+ label->place.y = cp->y;
+ }
+ } else /* not found, so we add it now */
+ label = store_label(plot->labels, cp, plot->boxplot_factors++, trimmed_string, 0.0);
free(trimmed_string);
return label->tag;
@@ -1556,7 +1564,7 @@
add_tic_user(
boxplot_labels_axis,
this_label->text,
- plot->points->x + i * boxplot_opts.separation,
+ this_label->place.x + i * boxplot_opts.separation,
-1);
i++;
this_label = this_label->next;
|