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

Commitfda4e5f

Browse files
committed
TST: add test
1 parentbfb7310 commitfda4e5f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

‎lib/matplotlib/colorbar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,8 @@ def _reset_locator_formatter_scale(self):
12121212
self._minorlocator=None
12131213
self._formatter=None
12141214
self._minorformatter=None
1215-
ifisinstance(self.norm,colors.LogNorm):
1215+
if (isinstance(self.mappable,contour.ContourSet)and
1216+
isinstance(self.norm,colors.LogNorm)):
12161217
# if contours have lognorm, give them a log scale...
12171218
self._set_scale('log')
12181219
elif (self.boundariesisnotNoneor

‎lib/matplotlib/tests/test_contour.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
importre
44

55
importcontourpy
6+
frommatplotlibimportticker
67
importnumpyasnp
78
fromnumpy.testingimportassert_array_almost_equal
89
importmatplotlibasmpl
@@ -154,6 +155,27 @@ def test_given_colors_levels_and_extends():
154155
plt.colorbar(c,ax=ax)
155156

156157

158+
@image_comparison(['contour_log_locator.png'],style='mpl20',remove_text=True)
159+
deftest_log_locator_levels():
160+
161+
fig,ax=plt.subplots()
162+
163+
N=100
164+
x=np.linspace(-3.0,3.0,N)
165+
y=np.linspace(-2.0,2.0,N)
166+
167+
X,Y=np.meshgrid(x,y)
168+
169+
Z1=np.exp(-X**2-Y**2)
170+
Z2=np.exp(-(X*10)**2- (Y*10)**2)
171+
data=Z1+50*Z2
172+
173+
c=ax.contourf(data,locator=ticker.LogLocator())
174+
assert_array_almost_equal(c.levels,np.power(10.0,np.arange(-6,3)))
175+
cb=fig.colorbar(c,ax=ax)
176+
assert_array_almost_equal(cb.ax.get_yticks(),c.levels)
177+
178+
157179
@image_comparison(['contour_datetime_axis.png'],style='mpl20')
158180
deftest_contour_datetime_axis():
159181
fig=plt.figure()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp