11#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 $" ); }
33#endif
44
55/* GNUPLOT - plot2d.c */
@@ -2718,11 +2718,7 @@ eval_plots()
27182718
27192719 /* Reset flags to auto-scale X axis to contents of data set */
27202720 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 ];
27262722 if (scaling_axis -> autoscale & AUTOSCALE_MIN )
27272723 scaling_axis -> min = VERYLARGE ;
27282724 if (scaling_axis -> autoscale & AUTOSCALE_MAX )
@@ -2962,18 +2958,25 @@ eval_plots()
29622958 axis_array [FIRST_X_AXIS ].max = 10 ;
29632959 }
29642960
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+ }
29672965
29682966 if (uses_axis [SECOND_X_AXIS ] & USES_AXIS_FOR_DATA ) {
29692967 /* check that x2min -> x2max is not too small */
29702968 axis_checked_extend_empty_range (SECOND_X_AXIS , "x2 range is invalid" );
29712969 } else if (axis_array [SECOND_X_AXIS ].autoscale ) {
29722970 /* 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+ }
29772980 }
29782981 }
29792982 if (some_functions ) {
@@ -3297,40 +3300,45 @@ eval_plots()
32973300 if (first_plot -> plot_type == NODATA )
32983301 int_error (NO_CARET ,"No data in plot" );
32993302
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+
33003320 if (uses_axis [FIRST_X_AXIS ]) {
33013321 if (axis_array [FIRST_X_AXIS ].max == - VERYLARGE ||
33023322 axis_array [FIRST_X_AXIS ].min == VERYLARGE )
33033323 int_error (NO_CARET , "all points undefined!" );
3304- axis_check_range (FIRST_X_AXIS );
3324+ } else {
3325+ assert (uses_axis [SECOND_X_AXIS ]);
33053326 }
33063327 if (uses_axis [SECOND_X_AXIS ]) {
33073328 if (axis_array [SECOND_X_AXIS ].max == - VERYLARGE ||
33083329 axis_array [SECOND_X_AXIS ].min == VERYLARGE )
33093330 int_error (NO_CARET , "all points undefined!" );
3310- axis_check_range (SECOND_X_AXIS );
33113331 } else {
3312- /* FIXME: If this triggers, doesn't it clobber linked axes? */
33133332 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 ;
33273333 }
3334+ axis_check_range (FIRST_X_AXIS );
3335+ axis_check_range (SECOND_X_AXIS );
33283336
3337+ /* For nonlinear axes, but must also be compatible with "set link x". */
33293338 /* min/max values were tracked during input for the visible axes. */
33303339 /* 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 ]);
33343342
33353343 if (this_plot && this_plot -> plot_style == TABLESTYLE ) {
33363344 /* the y axis range has no meaning in this case */
@@ -3347,18 +3355,16 @@ eval_plots()
33473355 axis_checked_extend_empty_range (SECOND_Y_AXIS , "all points y2 value undefined!" );
33483356 axis_check_range (SECOND_Y_AXIS );
33493357 } else {
3350- /* else we want to copy y2 range */
33513358 assert (uses_axis [FIRST_Y_AXIS ]);
33523359 if (axis_array [SECOND_Y_AXIS ].autoscale & AUTOSCALE_MIN )
33533360 axis_array [SECOND_Y_AXIS ].min = axis_array [FIRST_Y_AXIS ].min ;
33543361 if (axis_array [SECOND_Y_AXIS ].autoscale & AUTOSCALE_MAX )
33553362 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 */
33583363 if (! axis_array [SECOND_Y_AXIS ].autoscale )
33593364 axis_check_range (SECOND_Y_AXIS );
33603365 }
33613366 if (! uses_axis [FIRST_Y_AXIS ]) {
3367+ /* FIXME: probably unneeded or wrong since adding reconcile_linked_axes */
33623368 assert (uses_axis [SECOND_Y_AXIS ]);
33633369 if (axis_array [FIRST_Y_AXIS ].autoscale & AUTOSCALE_MIN )
33643370 axis_array [FIRST_Y_AXIS ].min = axis_array [SECOND_Y_AXIS ].min ;
@@ -3640,3 +3646,4 @@ reevaluate_plot_title(struct curve_points *this_plot)
36403646 }
36413647 }
36423648}
3649+
0 commit comments