FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix limit calculation of step* histogram by piti118 · Pull Request #1066 · matplotlib/matplotlib · GitHub

Repository navigation

fix limit calculation of step* histogram - #1066

Closed
piti118 wants to merge 1 commit into
matplotlib:masterfrom
piti118:histlimit2
Closed

piti118 wants to merge 1 commit into
matplotlib:masterfrom
piti118:histlimit2

Conversation

piti118 commented Aug 10, 2012

Copy link
Copy Markdown
Contributor

The limit calculation for histogram was switched for horizontal and vertical orientation.

Bar defines the vertical one as the one that x axis represents bin interval and y axis represent bin count.
The former one try to set y axis limit to bin interval for step* with vertical orientation which is wrong.

This PR fixed it.

Copy link
Copy Markdown
Member

Could you supply some code that demonstrates the problem? From a quick glance of the code, I would think it was correct.

piti118 commented Aug 12, 2012

Copy link
Copy Markdown
Contributor Author

Hmmm... actually. You are right the bug isn't where this change is but here is how to reproduce the bug. Sorry for long data. The short one with randn doesn't seems to reproduce the bug.

x = array([ 204872.484375,  203991.765625,  205687.8125  ,  204742.015625,
        203242.21875 ,  203915.421875,  204104.171875,  205327.      ,
        203688.828125,  205065.875   ,  204216.      ,  204971.671875,
        202821.      ,  202513.421875,  204655.28125 ,  204077.171875,
        204113.03125 ,  203609.640625,  205166.875   ,  203480.421875,
        205033.15625 ,  203545.359375,  205745.09375 ,  204191.5     ,
        204352.75    ,  205895.5     ,  203957.8125  ,  204922.      ,
        204926.46875 ,  203542.703125,  203439.734375,  204175.75    ,
        203235.671875,  204203.859375,  204364.859375,  202893.921875,
        204735.390625,  204109.34375 ,  203248.59375 ,  205474.8125  ,
        205579.3125  ,  205223.546875,  203747.859375,  203428.5625  ,
        204032.703125,  205342.      ,  203919.53125 ,  204935.609375,
        203799.171875,  205267.      ,  205811.4375  ,  205545.671875,
        204505.296875,  203193.171875,  204712.03125 ,  204869.328125,
        203978.984375,  204706.96875 ,  204281.59375 ,  206671.296875,
        205489.15625 ,  204234.625   ,  204288.1875  ,  203856.4375  ,
        202397.15625 ,  203842.34375 ,  204225.140625,  204723.484375,
        203921.671875,  203309.59375 ,  205585.265625,  205639.984375,
        204662.84375 ,  204669.375   ,  204697.140625,  204885.609375,
        204841.953125,  202966.359375,  203703.03125 ,  204063.8125  ,
        203600.125   ,  204758.28125 ,  203790.375   ,  204788.125   ,
        205213.09375 ,  203406.1875  ,  203743.640625,  205062.734375,
        204383.359375,  204062.1875  ,  204861.484375,  203959.59375 ,
        203386.21875 ,  204590.78125 ,  205909.      ,  204921.96875 ,
        204673.78125 ,  205823.03125 ,  203997.5     ,  204925.90625 ,
        204565.953125,  205387.84375 ,  203983.78125 ,  204911.9375  ,
        205802.546875,  203424.5     ,  204249.59375 ,  203936.09375 ,
        206172.09375 ,  203548.171875,  203882.015625,  204374.515625,
        204202.078125,  205384.3125  ,  205259.109375,  203466.09375 ,
        205665.765625,  205169.265625,  204005.046875,  204477.78125 ,
        204398.421875,  204829.125   ,  203448.859375,  204907.8125  ,
        204289.484375,  205328.4375  ,  204811.578125,  203218.109375,
        204250.28125 ,  204041.78125 ,  205668.21875 ,  203952.828125,
        205015.796875,  205242.703125,  204003.546875,  204847.53125 ,
        204988.015625,  203917.4375  ,  205779.21875 ,  203611.984375,
        204960.859375,  204531.625   ,  205578.6875  ,  203253.84375 ,
        204620.171875,  204516.96875 ,  204070.984375,  205448.65625 ,
        204623.328125,  204228.109375,  205392.203125,  205449.28125 ,
        202923.875   ,  203670.734375,  203380.890625,  206269.6875  ,
        204718.28125 ,  205592.15625 ,  204997.15625 ,  204224.703125,
        204141.828125,  205526.796875,  206984.296875,  204243.5     ,
        203661.71875 ,  203969.328125,  204256.125   ,  204657.65625 ,
        203087.515625,  205435.515625,  205679.015625,  205137.625   ,
        203510.421875,  204616.6875  ,  203742.125   ,  203595.203125,
        203721.390625,  204806.40625 ,  204765.3125  ,  204922.265625,
        205595.796875,  204131.4375  ,  204716.359375,  203827.890625,
        203850.296875,  204375.453125,  204600.578125,  205501.5     ,
        203517.90625 ,  203457.4375  ,  204287.828125,  203719.390625,
        204746.625   ,  204052.40625 ,  204075.34375 ,  204861.359375,
        206294.953125,  204334.171875,  203784.109375,  204637.75    ], dtype=float32)
#this one looks fine
hist(x,bins=40)
#but not this one
hist(x,bins=40,histtype='stepfilled')
#the y axis limit of this one is screwed up

piti118 commented Aug 12, 2012

Copy link
Copy Markdown
Contributor Author

Oh here is a more concise way to reproduce the bug:

y = randn(1000)+5000
hist(y,numbins=40,histtype='stepfilled')

The problem is this line, which I am not too sure why one want to do that. The minimum is the minimum bin interval value which has nothing to do with the y axis value.

ymin0 = max(_saved_bounds[1]*0.9, minimum)

piti118 commented Aug 12, 2012

Copy link
Copy Markdown
Contributor Author

Close see #1075 instead for the fix

piti118 closed this Aug 12, 2012
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL