Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27661fa

Browse files
committed
Fix case where axis limits are reversed
1 parent 5e162fb commit 27661fa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/widgets.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,12 +3654,23 @@ def _clip_to_axes(self, x, y):
36543654

36553655
min_lim = (xlim[0], ylim[0])
36563656
max_lim = (xlim[1], ylim[1])
3657+
36573658
# Axes limits in display coordinates
36583659
min_lim = self.ax.transData.transform(min_lim)
36593660
max_lim = self.ax.transData.transform(max_lim)
36603661

3662+
# For axes where the limits are reversed, need to make sure the
3663+
# display min/max are in the correct order.
3664+
3665+
if min_lim[0] > max_lim[0]:
3666+
min_lim[0], max_lim[0] = max_lim[0], min_lim[0]
3667+
3668+
if min_lim[1] > max_lim[1]:
3669+
min_lim[1], max_lim[1] = max_lim[1], min_lim[1]
3670+
36613671
x = np.clip(x, min_lim[0], max_lim[0])
36623672
y = np.clip(y, min_lim[1], max_lim[1])
3673+
36633674
return x, y
36643675

36653676
# TODO: _draw_shape can be removed in 3.7

0 commit comments

Comments
 (0)