diff --git a/control/sisotool.py b/control/sisotool.py index 2b735c0af..8a3b3d9f7 100644 --- a/control/sisotool.py +++ b/control/sisotool.py @@ -158,9 +158,11 @@ def _SisotoolUpdate(sys, fig, K, bode_plot_params, tvect=None): ax_phase.set_xlabel(ax_phase.get_xlabel(),fontsize=label_font_size) ax_phase.set_ylabel(ax_phase.get_ylabel(),fontsize=label_font_size) ax_phase.get_xaxis().set_label_coords(0.5, -0.15) - ax_phase.get_shared_x_axes().join(ax_phase, ax_mag) ax_phase.tick_params(axis='both', which='major', labelsize=label_font_size) + if not ax_phase.get_shared_x_axes().joined(ax_phase, ax_mag): + ax_phase.sharex(ax_mag) + ax_step.set_title('Step response',fontsize = title_font_size) ax_step.set_xlabel('Time (seconds)',fontsize=label_font_size) ax_step.set_ylabel('Output',fontsize=label_font_size) diff --git a/control/tests/sisotool_test.py b/control/tests/sisotool_test.py index d4a291052..fde5eba2b 100644 --- a/control/tests/sisotool_test.py +++ b/control/tests/sisotool_test.py @@ -83,6 +83,12 @@ def test_sisotool(self, tsys): 'margins': True } + # Check that the xaxes of the bode plot are shared before the rlocus click + assert ax_mag.get_xlim() == ax_phase.get_xlim() + ax_mag.set_xlim(2, 12) + assert ax_mag.get_xlim() == (2, 12) + assert ax_phase.get_xlim() == (2, 12) + # Move the rootlocus to another point event = type('test', (object,), {'xdata': 2.31206868287, 'ydata': 15.5983051046, @@ -116,6 +122,12 @@ def test_sisotool(self, tsys): assert_array_almost_equal( ax_step.lines[0].get_data()[1][:10], step_response_moved, 4) + # Check that the xaxes of the bode plot are still shared after the rlocus click + assert ax_mag.get_xlim() == ax_phase.get_xlim() + ax_mag.set_xlim(3, 13) + assert ax_mag.get_xlim() == (3, 13) + assert ax_phase.get_xlim() == (3, 13) + @pytest.mark.skipif(plt.get_current_fig_manager().toolbar is None, reason="Requires the zoom toolbar") @pytest.mark.parametrize('tsys', [0, True],