@@ -375,7 +375,7 @@ def streamlines(
375375 sys , revsys , timepts , X0 , params , dir ,
376376 gridtype = gridtype , gridspec = gridspec , xlim = xlim , ylim = ylim )
377377
378- # Plot the trajectory
378+ # Plot the trajectory (if there is one)
379379 if traj .shape [1 ] > 1 :
380380 out .append (
381381 ax .plot (traj [0 ], traj [1 ], color = color ))
@@ -596,6 +596,7 @@ def separatrices(
596596 color = unstable_color
597597 linestyle = '-'
598598
599+ # Plot the trajectory (if there is one)
599600 if traj .shape [1 ] > 1 :
600601 out .append (ax .plot (
601602 traj [0 ], traj [1 ], color = color , linestyle = linestyle ))
@@ -883,12 +884,13 @@ def _create_trajectory(
883884 gridtype = None , gridspec = None , xlim = None , ylim = None ):
884885 # Comput ethe forward trajectory
885886 if dir == 'forward' or dir == 'both' :
886- fwdresp = input_output_response (sys , timepts , X0 = X0 , params = params )
887+ fwdresp = input_output_response (
888+ sys , timepts , X0 = X0 , params = params , ignore_error = True )
887889
888890 # Compute the reverse trajectory
889891 if dir == 'reverse' or dir == 'both' :
890892 revresp = input_output_response (
891- revsys , timepts , X0 = X0 , params = params )
893+ revsys , timepts , X0 = X0 , params = params , ignore_error = True )
892894
893895 # Create the trace to plot
894896 if dir == 'forward' :
@@ -898,7 +900,14 @@ def _create_trajectory(
898900 elif dir == 'both' :
899901 traj = np .hstack ([revresp .states [:, :1 :- 1 ], fwdresp .states ])
900902
901- return traj
903+ # Remove points outside the window (keep first point beyond boundary)
904+ inrange = np .asarray (
905+ (traj [0 ] >= xlim [0 ]) & (traj [0 ] <= xlim [1 ]) &
906+ (traj [1 ] >= ylim [0 ]) & (traj [1 ] <= ylim [1 ]))
907+ inrange [:- 1 ] = inrange [:- 1 ] | inrange [1 :] # keep if next point in range
908+ inrange [1 :] = inrange [1 :] | inrange [:- 1 ] # keep if prev point in range
909+
910+ return traj [:, inrange ]
902911
903912
904913def _make_timepts (timepts , i ):
0 commit comments