|
From: Jouke W. <j.w...@gm...> - 2015-01-03 11:35:39
|
When a row in the datafile contains no factor, its y-value is stored in
place of the factor identifier, leading to ambiguities.
If the datafile contains
0 0 0 foo
0 1
The second row will be marked as part of the 'foo' boxplot.
This patch fixes that issue.
---
diff -Naur gnuplot-5.0.0.orig/src/gadgets.h gnuplot-5.0.0/src/gadgets.h
--- gnuplot-5.0.0.orig/src/gadgets.h 2015-01-02 22:06:25.488402227 +0100
+++ gnuplot-5.0.0/src/gadgets.h 2015-01-02 22:06:25.458403577 +0100
@@ -279,6 +279,8 @@
BOXPLOT_FACTOR_LABELS_X2
} t_boxplot_factor_labels;
+#define DEFAULT_BOXPLOT_FACTOR -1
+
typedef struct boxplot_style {
int limit_type; /* 0 = multiple of interquartile 1 = fraction of points */
double limit_value;
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-02 22:06:25.488402227 +0100
+++ gnuplot-5.0.0/src/plot2d.c 2015-01-02 22:08:57.411693594 +0100
@@ -910,19 +910,22 @@
store2d_point(current_plot, i++, v[0], v[1], v[0], v[0],
v[1] - v[2], v[1] + v[2], -1.0);
} else {
- double w;
+ double ylow, w;
if (current_plot->plot_style == CANDLESTICKS
|| current_plot->plot_style == FINANCEBARS) {
int_warn(storetoken, "This plot style does not work with 1 or 2 cols. Setting to points");
current_plot->plot_style = POINTSTYLE;
- }
+ } else if (current_plot->plot_style == BOXPLOT)
+ ylow = DEFAULT_BOXPLOT_FACTOR;
+ else
+ ylow = v[1];
if (current_plot->plot_smooth == SMOOTH_ACSPLINES)
w = 1.0; /* Unit weights */
else
w = -1.0; /* Auto-width boxes in some styles */
/* Set x/y high/low to exactly [x,y] */
store2d_point(current_plot, i++, v[0], v[1],
- v[0], v[0], v[1], v[1], w);
+ v[0], v[0], ylow, v[1], w);
}
break;
@@ -1004,7 +1007,7 @@
case BOXPLOT: /* x, y, width */
store2d_point(current_plot, i++, v[0], v[1], v[0]-v[2]/2., v[0]+v[2]/2.,
- v[1], v[1], v[2]);
+ DEFAULT_BOXPLOT_FACTOR, v[1], v[2]);
break;
#ifdef EAM_OBJECTS
@@ -1513,7 +1516,7 @@
/* This can happen if the user specifies a non-existent column:
* fall back to single-boxplot mode */
if (!string)
- return 0;
+ return DEFAULT_BOXPLOT_FACTOR;
/* Remove the trailing garbage, quotes etc. from the string */
trimmed_string = df_parse_string_field(string);
|