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

Skip to content

Commit 71e0c99

Browse files
committed
TST: hard-code nbins
Do not let the ticks in the inset adjust based on spacing of text which is not visible. The issue with the inset locator seems to be that as previously implemented the axis's estimate of how many ticks it should have was computed once and then saved. The way that the inset axes works (if you step through this line at a time) is that the figure-space size of the axes follows the x/y limits at a fixed ratio to the screen-space of the same range in the main axes. Thus, when the inset axes is created it is 'big' in that it has limits of [0, 1] at 6x zoom -> about half the size of the host axes and so it concludes that it needs a whole bunch of ticks and remembers that. One of the changes in this PR makes it so that the number of ticks is recomputed every time, thus many fewer ticks are used when the axes is small (even though the text is all turned off).
1 parent 027b563 commit 71e0c99

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ def get_demo_image():
134134
axins = zoomed_inset_axes(ax, 6, loc=1) # zoom = 6
135135
axins.imshow(Z2, extent=extent, interpolation="nearest",
136136
origin="lower")
137-
137+
axins.yaxis.get_major_locator().set_params(nbins=7)
138+
axins.xaxis.get_major_locator().set_params(nbins=7)
138139
# sub region of the original image
139140
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
140141
axins.set_xlim(x1, x2)

0 commit comments

Comments
 (0)