8000 Merge v2x to master by jenshnielsen · Pull Request #5906 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Merge v2x to master #5906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FIX: always use at least 2 ticks and recompute
For extreme aspect-ratio plots the auto ntick logic would decide that
no ticks will fit, leading to divide by 0 issue.

 - In ticker ensure there is always at least on bin
 - Axis do not cache the number of ticks so that if the on-screen
   aspect ratio changes the number of ticks will update correctly.
  • Loading branch information
tacaswell committed Jan 24, 2016
commit cefba05cc88e441e142a417f9993e4ceaf8095bc
4 changes: 2 additions & 2 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,7 @@ def get_tick_space(self):
# is no more than 3:1
size = tick.label1.get_size() * 3
size *= np.cos(np.deg2rad(tick.label1.get_rotation()))
self._tick_space = np.floor(length / size)
return np.floor(length / size)
return self._tick_space


Expand Down Expand Up @@ -2346,5 +2346,5 @@ def get_tick_space(self):
# Having a spacing of at least 2 just looks good.
size = tick.label1.get_size() * 2.0
size *= np.cos(np.deg2rad(tick.label1.get_rotation()))
self._tick_space = np.floor(length / size)
return np.floor(length / size)
return self._tick_space
2 changes: 1 addition & 1 deletion lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ def set_params(self, **kwargs):
def bin_boundaries(self, vmin, vmax):
nbins = self._nbins
if nbins == 'auto':
nbins = min(self.axis.get_tick_space(), 9)
nbins = max(min(self.axis.get_tick_space(), 9), 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be "2" at the end? (Just a wild guess...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a reasonable guess, but I think that at least originally, nbins was a maximum number of intervals, so the maximum number of ticks would be one larger; but all of this is dealing with maxima, not with any guaranteed number.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stated with 2 and change to 1 for exactly the reason @efiring stated.

scale, offset = scale_range(vmin, vmax, nbins)
if self._integer:
scale = max(1, scale)
Expand Down
0