Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Adjust number of ticks based on length of axis #5588
Conversation
mdboom
added this to the
next major release (2.0)
milestone
Nov 30, 2015
mdboom
added the
needs_review
label
Nov 30, 2015
tacaswell
commented on an outdated diff
Dec 1, 2015
| + *symmetric* | ||
| + If True, autoscaling will result in a range symmetric | ||
| + about zero. | ||
| + | ||
| + *prune* | ||
| + ['lower' | 'upper' | 'both' | None] | ||
| + Remove edge ticks -- useful for stacked or ganged plots | ||
| + where the upper tick of one axes overlaps with the lower | ||
| + tick of the axes above it. | ||
| + If prune=='lower', the smallest tick will | ||
| + be removed. If prune=='upper', the largest tick will be | ||
| + removed. If prune=='both', the largest and smallest ticks | ||
| + will be removed. If prune==None, no ticks will be removed. | ||
| + | ||
| + """ | ||
| + if 'nbins' in kwargs: |
|
|
tacaswell
and 1 other
commented on an outdated diff
Dec 1, 2015
| @@ -1449,6 +1449,48 @@ def view_limits(self, dmin, dmax): | ||
| return np.take(self.bin_boundaries(dmin, dmax), [0, -1]) | ||
| +class AutoSpacedLocator(MaxNLocator): | ||
| + """ | ||
| + Behaves like a MaxNLocator, except N is automatically determined | ||
| + from the length of the axis. | ||
| + """ | ||
| + def __init__(self, *args, **kwargs): |
|
|
tacaswell
and 1 other
commented on an outdated diff
Dec 1, 2015
| @@ -1872,7 +1914,13 @@ def tick_values(self, vmin, vmax): | ||
| return self.raise_if_exceeds(np.array(ticklocs)) | ||
| -class AutoLocator(MaxNLocator): |
tacaswell
Owner
|
|
|
You mean, raise an exception if it's there? |
|
Yes On Tue, Dec 1, 2015 at 6:22 PM Michael Droettboom notifications@github.com
|
|
Done. |
|
Does this mean that the default will now always be AutoLocator? And that a user will no longer be able to use |
|
@efiring: That's a good point. I've simplified this so that |
|
It might be better to use the string 'auto' as the default? It is clearer On Wed, Dec 2, 2015, 07:54 Michael Droettboom notifications@github.com
|
Sure. |
|
Right, "auto" is better for meaning automatic, meanwhile, None can continue On Wed, Dec 2, 2015 at 8:24 AM, Michael Droettboom <notifications@github.com
|
|
Good. Now, I am wondering whether there is any point in making the additional |
|
|
Just rebased. I think this is good-to-go once Travis passes. |
mdboom
added some commits
Nov 16, 2015
|
And... it's green (on Travis) |
efiring
added a commit
that referenced
this pull request
Dec 14, 2015
|
|
efiring |
7a29ad1
|
efiring
merged commit 7a29ad1
into matplotlib:master
Dec 14, 2015
efiring
removed the
needs_review
label
Dec 14, 2015
|
@mdboom, I suspect some corner cases will turn up and tweaks might be needed, but I think it makes sense to merge this so that it will get more exercise. |
|
Agreed. Thanks. |
|
This was merged to master, but the merge is in the v2.0.x branch. I think something fishy went on around b7c7c5e but I am not sure. |
efiring
added a commit
that referenced
this pull request
Dec 20, 2015
|
|
efiring + tacaswell |
7488da6
|
|
backported as 7488da6 |
|
@mdboom, I finally took a look to see what this does on master, with a minimal plot |
|
@efiring: You're suggesting a hard maximum? Just adding more space is unlikely to be a good fix, since in cases with many small axes you do want to allow the ticks to get reasonably close together. |
|
Yes, a hard maximum is what I had in mind. Then the behavior would not change for the default single-axes-per-figure case, but the multiple axes case would still be supported. |
|
Of course that hard maximum could be controllable with yet another rcParam if necessary. We didn't have one for that before, though. |
|
I'm fine with just setting the max to the old hard-coded value (which appears to be 9) and we can always add an rcParam later if people want more control. |
mdboom commentedNov 30, 2015
Follow on to #5494.