-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
tight_labels #801
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
tight_labels #801
Conversation
this looks related to #776, which also uses a heuristic, but one based on just the number of subplots created by the subplots command. |
I like this idea better. Haven't had a chance to look through it yet, but could it get extended to auto adjust font sizes or wrap text if we want a fixed number of tick labels, such as for bar graphs and other categorical plotting? |
@ivanov: Yes, we are trying to solve a same problem here, I believe. On the other hand, I think one thing that is better to be discussed is how we expose such functionality to the users, as your approach and mine is slightly different. My quick thought is that we may provide both . @WeatherGod: Yes, we can adjust the font size, or we can rotate the text. Also, I think it would be good if there are several heuristics that a user can select. |
This is a nice addition. Are there cases where #776 is provides a better solution than this or vice versa? If we're going to adjust font sizes, that should be a clear option -- in most cases, I want my font sizes to exactly match the font sizes of the surrounding document, so I don't want them scaled automatically, though I can imagine cases where the user wouldn't care. |
Besides documentation and tests, is there any reason why this PR should be held up? Would be nice to get this in before the feature freeze on the 20th. |
|
||
min_nbin = self.major.locator._nbins | ||
|
||
while self._get_label_occupy_fraction(renderer) < max_label_fraction: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to put in a safeguard here from getting stuck in an infinite loop? Is that a likely occurrence?
PR is 2 years old so I'm closing it. The concepts are good, but ideally this would be proposed via a MEP for non-technical discussion to take place before any implementation is attempted. |
This is my attempt to improve the situation of axis with too many ticks with overlapping ticklabels.
The overall idea is similar to tight_layout.
It calculates the fraction of the sum of ticklabel lengths (or heights) along the x-axis (or y-axis) over the axis length, and adjust the nbin value of tick locator until it satisfies some criteria.
Here is a simple usage.
This PR is just to toss around ideas. It may have some problems with shared axes.
Also, I'm not quite happy with the current heuristics, and want to play with other heuristics.