diff --git a/src/gmt_plot.c b/src/gmt_plot.c index 3825e23ec5d..fe2c8fe103f 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -6155,6 +6155,11 @@ GMT_LOCAL void gmtplot_get_outside_point_extension (struct GMT_CTRL *GMT, double L = 0.0; else /* Safe to get width (but still truncate to width of map) */ L = MIN (fabs (W / tan_angle), GMT->current.map.half_width); /* L is positive */ + /* For lines that cross the border at a shallow (near-tangent) angle, L can blow up far beyond + * the segment that defines the crossing direction, producing a visible stray line segment + * (https://github.com/GenericMappingTools/gmt/issues/5954). The extension should never need + * to reach further than the segment itself, so cap it at that segment's length. */ + L = MIN (L, hypot (dx, dy)); /* Compute the coordinates of the point at a distance L away from clip point in the direction of angle */ *x_off = x_on - L * cosd (angle); *y_off = y_on - L * sind (angle); diff --git a/src/seis/pssac.c b/src/seis/pssac.c index 67394d45431..fcc6e895fbf 100644 --- a/src/seis/pssac.c +++ b/src/seis/pssac.c @@ -674,6 +674,8 @@ EXTERN_MSC int GMT_pssac (void *V_API, int mode, void *args) { /* High-level fun } GMT_Report (API, GMT_MSG_INFORMATION, "Collecting %ld SAC files to plot.\n", n_files); + gmt_map_clip_on (GMT, GMT->session.no_rgb, 3); /* Clip to map so border-crossing traces don't leak stray pen segments outside the frame */ + for (n = 0; n < (int)n_files; n++) { /* Loop over all SAC files */ GMT_Report (API, GMT_MSG_INFORMATION, "Plotting SAC file %d: %s\n", n, L[n].file); @@ -937,6 +939,8 @@ EXTERN_MSC int GMT_pssac (void *V_API, int mode, void *args) { /* High-level fun gmt_M_free (GMT, L); gmt_M_free (GMT, Ctrl->In.file); + gmt_map_clip_off (GMT); + if (Ctrl->D.active) PSL_setorigin (PSL, -Ctrl->D.dx, -Ctrl->D.dy, 0.0, PSL_FWD); /* Reset shift */ PSL_setdash (PSL, NULL, 0);