Skip to content

Commit 55730b6

Browse files
authored
Merge pull request #834 from bnavigator/fix-sisotool-mpl-deprecation
Sisotool: Fix Matplotlib deprecation of axis share handling
2 parents 9cef661 + b7baec0 commit 55730b6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

control/sisotool.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ def _SisotoolUpdate(sys, fig, K, bode_plot_params, tvect=None):
158158
ax_phase.set_xlabel(ax_phase.get_xlabel(),fontsize=label_font_size)
159159
ax_phase.set_ylabel(ax_phase.get_ylabel(),fontsize=label_font_size)
160160
ax_phase.get_xaxis().set_label_coords(0.5, -0.15)
161-
ax_phase.get_shared_x_axes().join(ax_phase, ax_mag)
162161
ax_phase.tick_params(axis='both', which='major', labelsize=label_font_size)
163162

163+
if not ax_phase.get_shared_x_axes().joined(ax_phase, ax_mag):
164+
ax_phase.sharex(ax_mag)
165+
164166
ax_step.set_title('Step response',fontsize = title_font_size)
165167
ax_step.set_xlabel('Time (seconds)',fontsize=label_font_size)
166168
ax_step.set_ylabel('Output',fontsize=label_font_size)

control/tests/sisotool_test.py

+12
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ def test_sisotool(self, tsys):
8383
'margins': True
8484
}
8585

86+
# Check that the xaxes of the bode plot are shared before the rlocus click
87+
assert ax_mag.get_xlim() == ax_phase.get_xlim()
88+
ax_mag.set_xlim(2, 12)
89+
assert ax_mag.get_xlim() == (2, 12)
90+
assert ax_phase.get_xlim() == (2, 12)
91+
8692
# Move the rootlocus to another point
8793
event = type('test', (object,), {'xdata': 2.31206868287,
8894
'ydata': 15.5983051046,
@@ -116,6 +122,12 @@ def test_sisotool(self, tsys):
116122
assert_array_almost_equal(
117123
ax_step.lines[0].get_data()[1][:10], step_response_moved, 4)
118124

125+
# Check that the xaxes of the bode plot are still shared after the rlocus click
126+
assert ax_mag.get_xlim() == ax_phase.get_xlim()
127+
ax_mag.set_xlim(3, 13)
128+
assert ax_mag.get_xlim() == (3, 13)
129+
assert ax_phase.get_xlim() == (3, 13)
130+
119131
@pytest.mark.skipif(plt.get_current_fig_manager().toolbar is None,
120132
reason="Requires the zoom toolbar")
121133
@pytest.mark.parametrize('tsys', [0, True],

0 commit comments

Comments
 (0)