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

Commitf24d06c

Browse files
committed
zero area rects no longer influence auto-scaling
svn path=/trunk/matplotlib/; revision=5285
1 parent3061f58 commitf24d06c

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

‎API_CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Rewrote the cm.ScalarMappable callback infrastructure to use
23
cbook.CallbackRegistry rather than custom callback handling. Amy
34
users of add_observer/notify of the cm.ScalarMappable should uae

‎CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2008-05-28 zero width/height Rectangles no longer influence the
2+
autoscaler. Useful for log histograms with empty bins -
3+
JDH
4+
15
2008-05-28 Fix rendering of composite glyphs in Type 3 conversion
26
(particularly as evidenced in the Eunjin.ttf Korean font)
37
Thanks Jae-Joon Lee for finding this!

‎lib/matplotlib/axes.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,10 +1230,18 @@ def add_patch(self, p):
12301230

12311231
def_update_patch_limits(self,p):
12321232
'update the datalimits for patch p'
1233+
# hist can add zero height Rectangles, which is useful to keep
1234+
# the bins, counts and patches lined up, but it throws off log
1235+
# scaling. We'll ignore rects with zero height or width in
1236+
# the auto-scaling
1237+
ifisinstance(p,mpatches.Rectangle)andp.get_width()==0.orp.get_height()==0.:
1238+
return
1239+
12331240
vertices=p.get_patch_transform().transform(p.get_path().vertices)
12341241
ifp.get_data_transform()!=self.transData:
12351242
transform=p.get_data_transform()+self.transData.inverted()
12361243
xys=transform.transform(vertices)
1244+
12371245
self.update_datalim(vertices)
12381246

12391247
defadd_table(self,tab):
@@ -3509,14 +3517,15 @@ def make_iterable(x):
35093517

35103518
ifadjust_xlim:
35113519
xmin,xmax=self.dataLim.intervalx
3512-
xmin=np.amin(width)
3520+
xmin=np.amin(width[width!=0])# filter out the 0 width rects
35133521
ifxerrisnotNone:
35143522
xmin=xmin-np.amax(xerr)
35153523
xmin=max(xmin*0.9,1e-100)
35163524
self.dataLim.intervalx= (xmin,xmax)
3525+
35173526
ifadjust_ylim:
35183527
ymin,ymax=self.dataLim.intervaly
3519-
ymin=np.amin(height)
3528+
ymin=np.amin(height[height!=0])# filter out the 0 height rects
35203529
ifyerrisnotNone:
35213530
ymin=ymin-np.amax(yerr)
35223531
ymin=max(ymin*0.9,1e-100)
@@ -5501,7 +5510,10 @@ def hist(self, x, bins=10, normed=False, cumulative=False,
55015510
width. If None, automatically compute the width. Ignored
55025511
for 'step' histtype.
55035512
5504-
log: if True, the histogram axis will be set to a log scale
5513+
log: if True, the histogram axis will be set to a log scale.
5514+
If log is true and x is a 1D array, empty bins will be
5515+
filtered out and only the non-empty n, bins, patches will be
5516+
returned.
55055517
55065518
kwargs are used to update the properties of the
55075519
hist Rectangles:
@@ -5587,6 +5599,7 @@ def hist(self, x, bins=10, normed=False, cumulative=False,
55875599
ccount+=1
55885600
eliforientation=='vertical':
55895601
forminn:
5602+
55905603
color=colors[ccount%len(colors)]
55915604
patch=self.bar(bins[:-1]+boffset,m,width=width,
55925605
bottom=bottom,align='center',log=log,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp