Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbeec816

Browse files
committed
Fix interaction between sticky_edges and shared axes.
1 parent53c8d6a commitbeec816

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,14 +2436,19 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
24362436
iftightisnotNone:
24372437
self._tight=bool(tight)
24382438

2439-
ifself.use_sticky_edgesand (
2440-
(self._xmarginandscalexandself._autoscaleXon)or
2441-
(self._ymarginandscaleyandself._autoscaleYon)):
2442-
stickies= [artist.sticky_edgesforartistinself.get_children()]
2443-
else:# Small optimization.
2444-
stickies= []
2445-
x_stickies=np.sort([xforstickyinstickiesforxinsticky.x])
2446-
y_stickies=np.sort([yforstickyinstickiesforyinsticky.y])
2439+
x_stickies=y_stickies=np.array([])
2440+
ifself.use_sticky_edges:
2441+
# Only iterate over axes and artists if needed.
2442+
ifself._xmarginandscalexandself._autoscaleXon:
2443+
x_stickies=np.sort(np.concatenate([
2444+
artist.sticky_edges.x
2445+
foraxinself._shared_x_axes.get_siblings(self)
2446+
forartistinax.get_children()]))
2447+
ifself._ymarginandscaleyandself._autoscaleYon:
2448+
y_stickies=np.sort(np.concatenate([
2449+
artist.sticky_edges.y
2450+
foraxinself._shared_y_axes.get_siblings(self)
2451+
forartistinax.get_children()]))
24472452
ifself.get_xscale().lower()=='log':
24482453
x_stickies=x_stickies[x_stickies>0]
24492454
ifself.get_yscale().lower()=='log':

‎lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,21 @@ def test_use_sticky_edges():
398398
assert_allclose(ax.get_ylim(), (-0.5,1.5))
399399

400400

401+
@check_figures_equal(extensions=["png"])
402+
deftest_sticky_shared_axes(fig_test,fig_ref):
403+
# Check that sticky edges work whether they are set in an axes that is a
404+
# "master" in a share, or an axes that is a "follower".
405+
Z=np.arange(15).reshape(3,5)
406+
407+
ax0=fig_test.add_subplot(211)
408+
ax1=fig_test.add_subplot(212,sharex=ax0)
409+
ax1.pcolormesh(Z)
410+
411+
ax0=fig_ref.add_subplot(212)
412+
ax1=fig_ref.add_subplot(211,sharex=ax0)
413+
ax0.pcolormesh(Z)
414+
415+
401416
@image_comparison(['offset_points'],remove_text=True)
402417
deftest_basic_annotate():
403418
# Setup some data

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp