=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/Attic/plot2d.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -p -r1.1.1.1 -r1.1.1.2 --- OpenXM_contrib/gnuplot/Attic/plot2d.c 2000/01/09 17:00:54 1.1.1.1 +++ OpenXM_contrib/gnuplot/Attic/plot2d.c 2000/01/22 14:15:59 1.1.1.2 @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: plot2d.c,v 1.1.1.1 2000/01/09 17:00:54 maekawa Exp $"; +static char *RCSid = "$Id: plot2d.c,v 1.1.1.2 2000/01/22 14:15:59 maekawa Exp $"; #endif /* GNUPLOT - plot2d.c */ @@ -288,7 +288,8 @@ struct curve_points *this_plot; * it will later be moved passed title/with/linetype/pointtype */ { - register int i /* num. points ! */ , j, col; + int i /* num. points ! */ , j; + int max_cols, min_cols; /* allowed range of column numbers */ double v[NCOL]; int storetoken = this_plot->token; @@ -297,38 +298,51 @@ struct curve_points *this_plot; switch (this_plot->plot_style) { /* set maximum columns to scan */ case XYERRORBARS: case BOXXYERROR: - col = 7; + max_cols = 7; + min_cols = 4; break; - case BOXERROR: case FINANCEBARS: case CANDLESTICKS: - col = 5; + min_cols = max_cols = 5; break; + case BOXERROR: + max_cols = 5; + min_cols = 4; + break; + + case VECTOR: + min_cols = max_cols = 4; + break; + case XERRORBARS: case YERRORBARS: - case VECTOR: - col = 4; + max_cols = 4; + min_cols = 3; break; case BOXES: - col = 4; - break; + min_cols = 2; + max_cols = 4; default: - col = 2; + min_cols = 1; + max_cols = 2; } if (this_plot->plot_smooth == ACSPLINES) - col = 3; + max_cols = 3; - if (df_no_use_specs > col) - fputs("warning : too many using specs for this style\n", stderr); + if (df_no_use_specs > max_cols) + int_error("Too many using specs for this style", NO_CARET); + if (df_no_use_specs >0 && df_no_use_specs < min_cols) + int_error("Not enough columns for this style", NO_CARET); + i = 0; - while ((j = df_readline(v, col)) != DF_EOF) { - /* j <= col */ + while ((j = df_readline(v, max_cols)) != DF_EOF) { + /* j <= max_cols */ if (i >= this_plot->p_max) { /* @@ -1194,6 +1208,8 @@ do{ assert(!polar && !parametric); \ if (plot_num == 0 || first_plot == NULL) { int_error("no functions or data to plot", c_token); } + + if (uses_axis[FIRST_X_AXIS]) { if (max_array[FIRST_X_AXIS] == -VERYLARGE || min_array[FIRST_X_AXIS] == VERYLARGE) @@ -1211,8 +1227,9 @@ do{ assert(!polar && !parametric); \ min_array[SECOND_X_AXIS] = min_array[FIRST_X_AXIS]; if (auto_array[SECOND_X_AXIS] & 2) max_array[SECOND_X_AXIS] = max_array[FIRST_X_AXIS]; + if (! auto_array[SECOND_X_AXIS]) + FIXUP_RANGE_FOR_LOG(SECOND_X_AXIS, x2); } - if (!uses_axis[FIRST_X_AXIS]) { assert(uses_axis[SECOND_X_AXIS]); if (auto_array[FIRST_X_AXIS] & 1) @@ -1220,13 +1237,15 @@ do{ assert(!polar && !parametric); \ if (auto_array[FIRST_X_AXIS] & 2) max_array[FIRST_X_AXIS] = max_array[SECOND_X_AXIS]; } + + if (uses_axis[FIRST_Y_AXIS]) { if (max_array[FIRST_Y_AXIS] == -VERYLARGE || min_array[FIRST_Y_AXIS] == VERYLARGE) int_error("all points undefined!", NO_CARET); fixup_range(FIRST_Y_AXIS, "y"); FIXUP_RANGE_FOR_LOG(FIRST_Y_AXIS, y); - } /* else we want to copy y2 range, but need to fix it up first */ + } if (uses_axis[SECOND_Y_AXIS]) { if (max_array[SECOND_Y_AXIS] == -VERYLARGE || min_array[SECOND_Y_AXIS] == VERYLARGE) @@ -1234,13 +1253,17 @@ do{ assert(!polar && !parametric); \ fixup_range(SECOND_Y_AXIS, "y2"); FIXUP_RANGE_FOR_LOG(SECOND_Y_AXIS, y2); } else { + /* else we want to copy y2 range */ assert(uses_axis[FIRST_Y_AXIS]); if (auto_array[SECOND_Y_AXIS] & 1) min_array[SECOND_Y_AXIS] = min_array[FIRST_Y_AXIS]; if (auto_array[SECOND_Y_AXIS] & 2) max_array[SECOND_Y_AXIS] = max_array[FIRST_Y_AXIS]; + /* Log() fixup is only necessary if the range was *not* copied from + * the (already logarithmized) yrange */ + if (! auto_array[SECOND_Y_AXIS]) + FIXUP_RANGE_FOR_LOG(SECOND_Y_AXIS, y2); } - if (!uses_axis[FIRST_Y_AXIS]) { assert(uses_axis[SECOND_Y_AXIS]); if (auto_array[FIRST_Y_AXIS] & 1) @@ -1248,6 +1271,7 @@ do{ assert(!polar && !parametric); \ if (auto_array[FIRST_Y_AXIS] & 2) max_array[FIRST_Y_AXIS] = max_array[SECOND_Y_AXIS]; } + #define WRITEBACK(axis,min,max) \ if(range_flags[axis]&RANGE_WRITEBACK) \ {if (auto_array[axis]&1) min = min_array[axis]; \ @@ -1258,7 +1282,8 @@ if(range_flags[axis]&RANGE_WRITEBACK) \ WRITEBACK(FIRST_Y_AXIS, ymin, ymax) WRITEBACK(SECOND_X_AXIS, x2min, x2max) WRITEBACK(SECOND_Y_AXIS, y2min, y2max) - if (strcmp(term->name, "table") == 0) + + if (strcmp(term->name, "table") == 0) print_table(first_plot, plot_num); else { START_LEAK_CHECK(); /* check for memory leaks in this routine */