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

Commitf19fea6

Browse files
committed
Merge pull request#5700 from efiring/colorbar_tick_trim
BUG: handle colorbar ticks with boundaries and NoNorm;closes#5673used master branch pngs
1 parent5d90618 commitf19fea6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

‎lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def _ticker(self):
580580
else:
581581
b=self._boundaries[self._inside]
582582
locator=ticker.FixedLocator(b,nbins=10)
583-
ifisinstance(self.norm,colors.NoNorm):
583+
ifisinstance(self.norm,colors.NoNorm)andself.boundariesisNone:
584584
intv=self._values[0],self._values[-1]
585585
else:
586586
intv=self.vmin,self.vmax

‎lib/matplotlib/tests/test_colorbar.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,22 @@ def test_colorbar_closed_patch():
282282
extend='neither',values=values)
283283

284284

285+
@cleanup
286+
deftest_colorbar_ticks():
287+
# test fix for #5673
288+
fig,ax=plt.subplots()
289+
x=np.arange(-3.0,4.001)
290+
y=np.arange(-4.0,3.001)
291+
X,Y=np.meshgrid(x,y)
292+
Z=X*Y
293+
clevs=np.array([-12,-5,0,5,12],dtype=float)
294+
colors= ['r','g','b','c']
295+
cs=ax.contourf(X,Y,Z,clevs,colors=colors)
296+
cbar=fig.colorbar(cs,ax=ax,extend='neither',
297+
orientation='horizontal',ticks=clevs)
298+
assertlen(cbar.ax.xaxis.get_ticklocs())==len(clevs)
299+
300+
285301
if__name__=='__main__':
286302
importnose
287303
nose.runmodule(argv=['-s','--with-doctest'],exit=False)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp