1
1
#ifndef lint
2
- static char * RCSid () { return RCSid ("$Id: plot2d.c,v 1.459 2017-09-29 19:23:37 sfeam Exp $" ); }
2
+ static char * RCSid () { return RCSid ("$Id: plot2d.c,v 1.460 2017-10-09 00:49:03 sfeam Exp $" ); }
3
3
#endif
4
4
5
5
/* GNUPLOT - plot2d.c */
@@ -2718,11 +2718,7 @@ eval_plots()
2718
2718
2719
2719
/* Reset flags to auto-scale X axis to contents of data set */
2720
2720
if (!(uses_axis [x_axis ] & USES_AXIS_FOR_DATA ) && X_AXIS .autoscale ) {
2721
- struct axis * scaling_axis ;
2722
- if (x_axis == SECOND_X_AXIS && !X_AXIS .linked_to_primary )
2723
- scaling_axis = & axis_array [SECOND_X_AXIS ];
2724
- else
2725
- scaling_axis = & axis_array [FIRST_X_AXIS ];
2721
+ struct axis * scaling_axis = & axis_array [this_plot -> x_axis ];
2726
2722
if (scaling_axis -> autoscale & AUTOSCALE_MIN )
2727
2723
scaling_axis -> min = VERYLARGE ;
2728
2724
if (scaling_axis -> autoscale & AUTOSCALE_MAX )
@@ -2962,18 +2958,25 @@ eval_plots()
2962
2958
axis_array [FIRST_X_AXIS ].max = 10 ;
2963
2959
}
2964
2960
2965
- /* check that xmin -> xmax is not too small */
2966
- axis_checked_extend_empty_range (FIRST_X_AXIS , "x range is invalid" );
2961
+ if (uses_axis [FIRST_X_AXIS ] & USES_AXIS_FOR_DATA ) {
2962
+ /* check that x1min -> x1max is not too small */
2963
+ axis_checked_extend_empty_range (FIRST_X_AXIS , "x range is invalid" );
2964
+ }
2967
2965
2968
2966
if (uses_axis [SECOND_X_AXIS ] & USES_AXIS_FOR_DATA ) {
2969
2967
/* check that x2min -> x2max is not too small */
2970
2968
axis_checked_extend_empty_range (SECOND_X_AXIS , "x2 range is invalid" );
2971
2969
} else if (axis_array [SECOND_X_AXIS ].autoscale ) {
2972
2970
/* copy x1's range */
2973
- if (axis_array [SECOND_X_AXIS ].autoscale & AUTOSCALE_MIN )
2974
- axis_array [SECOND_X_AXIS ].min = axis_array [FIRST_X_AXIS ].min ;
2975
- if (axis_array [SECOND_X_AXIS ].autoscale & AUTOSCALE_MAX )
2976
- axis_array [SECOND_X_AXIS ].max = axis_array [FIRST_X_AXIS ].max ;
2971
+ /* FIXME: merge both cases into update_secondary_axis_range */
2972
+ if (axis_array [SECOND_X_AXIS ].linked_to_primary ) {
2973
+ update_secondary_axis_range (& axis_array [FIRST_X_AXIS ]);
2974
+ } else {
2975
+ if (axis_array [SECOND_X_AXIS ].autoscale & AUTOSCALE_MIN )
2976
+ axis_array [SECOND_X_AXIS ].min = axis_array [FIRST_X_AXIS ].min ;
2977
+ if (axis_array [SECOND_X_AXIS ].autoscale & AUTOSCALE_MAX )
2978
+ axis_array [SECOND_X_AXIS ].max = axis_array [FIRST_X_AXIS ].max ;
2979
+ }
2977
2980
}
2978
2981
}
2979
2982
if (some_functions ) {
@@ -3297,40 +3300,45 @@ eval_plots()
3297
3300
if (first_plot -> plot_type == NODATA )
3298
3301
int_error (NO_CARET ,"No data in plot" );
3299
3302
3303
+ /* gnuplot version 5.0 always used x1 to track autoscaled range
3304
+ * regardless of whether x1 or x2 was used to plot the data.
3305
+ * In version 5.2 we track the x1/x2 axis data limits separately.
3306
+ * However if x1 and x2 are linked to each other we must now
3307
+ * reconcile their data limits before plotting.
3308
+ */
3309
+ if (uses_axis [FIRST_X_AXIS ] && uses_axis [SECOND_X_AXIS ]) {
3310
+ AXIS * primary = & axis_array [FIRST_X_AXIS ];
3311
+ AXIS * secondary = & axis_array [SECOND_X_AXIS ];
3312
+ reconcile_linked_axes (primary , secondary );
3313
+ }
3314
+ if (uses_axis [FIRST_Y_AXIS ] && uses_axis [SECOND_Y_AXIS ]) {
3315
+ AXIS * primary = & axis_array [FIRST_Y_AXIS ];
3316
+ AXIS * secondary = & axis_array [SECOND_Y_AXIS ];
3317
+ reconcile_linked_axes (primary , secondary );
3318
+ }
3319
+
3300
3320
if (uses_axis [FIRST_X_AXIS ]) {
3301
3321
if (axis_array [FIRST_X_AXIS ].max == - VERYLARGE ||
3302
3322
axis_array [FIRST_X_AXIS ].min == VERYLARGE )
3303
3323
int_error (NO_CARET , "all points undefined!" );
3304
- axis_check_range (FIRST_X_AXIS );
3324
+ } else {
3325
+ assert (uses_axis [SECOND_X_AXIS ]);
3305
3326
}
3306
3327
if (uses_axis [SECOND_X_AXIS ]) {
3307
3328
if (axis_array [SECOND_X_AXIS ].max == - VERYLARGE ||
3308
3329
axis_array [SECOND_X_AXIS ].min == VERYLARGE )
3309
3330
int_error (NO_CARET , "all points undefined!" );
3310
- axis_check_range (SECOND_X_AXIS );
3311
3331
} else {
3312
- /* FIXME: If this triggers, doesn't it clobber linked axes? */
3313
3332
assert (uses_axis [FIRST_X_AXIS ]);
3314
- if (axis_array [SECOND_X_AXIS ].autoscale & AUTOSCALE_MIN )
3315
- axis_array [SECOND_X_AXIS ].min = axis_array [FIRST_X_AXIS ].min ;
3316
- if (axis_array [SECOND_X_AXIS ].autoscale & AUTOSCALE_MAX )
3317
- axis_array [SECOND_X_AXIS ].max = axis_array [FIRST_X_AXIS ].max ;
3318
- if (! axis_array [SECOND_X_AXIS ].autoscale )
3319
- axis_check_range (SECOND_X_AXIS );
3320
- }
3321
- if (! uses_axis [FIRST_X_AXIS ]) {
3322
- assert (uses_axis [SECOND_X_AXIS ]);
3323
- if (axis_array [FIRST_X_AXIS ].autoscale & AUTOSCALE_MIN )
3324
- axis_array [FIRST_X_AXIS ].min = axis_array [SECOND_X_AXIS ].min ;
3325
- if (axis_array [FIRST_X_AXIS ].autoscale & AUTOSCALE_MAX )
3326
- axis_array [FIRST_X_AXIS ].max = axis_array [SECOND_X_AXIS ].max ;
3327
3333
}
3334
+ axis_check_range (FIRST_X_AXIS );
3335
+ axis_check_range (SECOND_X_AXIS );
3328
3336
3337
+ /* For nonlinear axes, but must also be compatible with "set link x". */
3329
3338
/* min/max values were tracked during input for the visible axes. */
3330
3339
/* Now we use them to update the corresponding shadow (nonlinear) ones. */
3331
- update_primary_axis_range (& axis_array [FIRST_X_AXIS ]);
3332
- update_primary_axis_range (& axis_array [SECOND_X_AXIS ]);
3333
-
3340
+ update_primary_axis_range (& axis_array [FIRST_X_AXIS ]);
3341
+ update_primary_axis_range (& axis_array [SECOND_X_AXIS ]);
3334
3342
3335
3343
if (this_plot && this_plot -> plot_style == TABLESTYLE ) {
3336
3344
/* the y axis range has no meaning in this case */
@@ -3347,18 +3355,16 @@ eval_plots()
3347
3355
axis_checked_extend_empty_range (SECOND_Y_AXIS , "all points y2 value undefined!" );
3348
3356
axis_check_range (SECOND_Y_AXIS );
3349
3357
} else {
3350
- /* else we want to copy y2 range */
3351
3358
assert (uses_axis [FIRST_Y_AXIS ]);
3352
3359
if (axis_array [SECOND_Y_AXIS ].autoscale & AUTOSCALE_MIN )
3353
3360
axis_array [SECOND_Y_AXIS ].min = axis_array [FIRST_Y_AXIS ].min ;
3354
3361
if (axis_array [SECOND_Y_AXIS ].autoscale & AUTOSCALE_MAX )
3355
3362
axis_array [SECOND_Y_AXIS ].max = axis_array [FIRST_Y_AXIS ].max ;
3356
- /* Log() fixup is only necessary if the range was *not* copied from
3357
- * the (already logarithmized) yrange */
3358
3363
if (! axis_array [SECOND_Y_AXIS ].autoscale )
3359
3364
axis_check_range (SECOND_Y_AXIS );
3360
3365
}
3361
3366
if (! uses_axis [FIRST_Y_AXIS ]) {
3367
+ /* FIXME: probably unneeded or wrong since adding reconcile_linked_axes */
3362
3368
assert (uses_axis [SECOND_Y_AXIS ]);
3363
3369
if (axis_array [FIRST_Y_AXIS ].autoscale & AUTOSCALE_MIN )
3364
3370
axis_array [FIRST_Y_AXIS ].min = axis_array [SECOND_Y_AXIS ].min ;
@@ -3640,3 +3646,4 @@ reevaluate_plot_title(struct curve_points *this_plot)
3640
3646
}
3641
3647
}
3642
3648
}
3649
+
0 commit comments