Merge pull request #863 from henklaak/main · python-control/python-control@346bc40
@@ -276,18 +276,21 @@ def bode_plot(syslist, omega=None,
276276if initial_phase is None:
277277# Start phase in the range 0 to -360 w/ initial phase = -180
278278# If wrap_phase is true, use 0 instead (phase \in (-pi, pi])
279-initial_phase = -math.pi if wrap_phase is not True else 0
279+initial_phase_value = -math.pi if wrap_phase is not True else 0
280280elif isinstance(initial_phase, (int, float)):
281281# Allow the user to override the default calculation
282282if deg:
283-initial_phase = initial_phase/180. * math.pi
283+initial_phase_value = initial_phase/180. * math.pi
284+else:
285+initial_phase_value = initial_phase
286+284287else:
285288raise ValueError("initial_phase must be a number.")
286289287290# Shift the phase if needed
288-if abs(phase[0] - initial_phase) > math.pi:
291+if abs(phase[0] - initial_phase_value) > math.pi:
289292phase -= 2*math.pi * \
290-round((phase[0] - initial_phase) / (2*math.pi))
293+round((phase[0] - initial_phase_value) / (2*math.pi))
291294292295# Phase wrapping
293296if wrap_phase is False:
@@ -1021,9 +1024,11 @@ def _parse_linestyle(style_name, allow_false=False):
10211024# Plot the scaled sections of the curve (changing linestyle)
10221025x_scl = np.ma.masked_where(scale_mask, resp.real)
10231026y_scl = np.ma.masked_where(scale_mask, resp.imag)
1024-plt.plot(
1025-x_scl * (1 + curve_offset), y_scl * (1 + curve_offset),
1026-primary_style[1], color=c, **kwargs)
1027+if x_scl.count() >= 1 and y_scl.count() >= 1:
1028+plt.plot(
1029+x_scl * (1 + curve_offset),
1030+y_scl * (1 + curve_offset),
1031+primary_style[1], color=c, **kwargs)
1027103210281033# Plot the primary curve (invisible) for setting arrows
10291034x, y = resp.real.copy(), resp.imag.copy()
@@ -1041,10 +1046,11 @@ def _parse_linestyle(style_name, allow_false=False):
10411046# Plot the regular and scaled segments
10421047plt.plot(
10431048x_reg, -y_reg, mirror_style[0], color=c, **kwargs)
1044-plt.plot(
1045-x_scl * (1 - curve_offset),
1046--y_scl * (1 - curve_offset),
1047-mirror_style[1], color=c, **kwargs)
1049+if x_scl.count() >= 1 and y_scl.count() >= 1:
1050+plt.plot(
1051+x_scl * (1 - curve_offset),
1052+-y_scl * (1 - curve_offset),
1053+mirror_style[1], color=c, **kwargs)
1048105410491055# Add the arrows (on top of an invisible contour)
10501056x, y = resp.real.copy(), resp.imag.copy()