Skip to content

Sisotool: Fix Matplotlib deprecation of axis share handling #834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion control/sisotool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions control/tests/sisotool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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],
Expand Down