| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… tests cases to fit, added next_api_changes
| font_ratio = (rcParams['font.size'])/10 | ||
|
|
||
| # a ratio of 10 date characters per inch is 'estimated' | ||
| maxwid = rcParams["figure.figsize"][0] * 10 |
There was a problem hiding this comment.
I think you need to get the width of the axes, not the figure. I'd also expect 10-pt font characters to be about 72 points-per-inch / 10 points-per-character = 7.2 characters-per-inch wide.
Sorry, something went wrong.
There was a problem hiding this comment.
Font size generally refers to the height, not the width (i.e., 10pt monospace, sans, serif are not all the same width).
Sorry, something went wrong.
There was a problem hiding this comment.
Understood, but IMO, the new ticks are too spread out. 1) because using the wrong width to work over and 2) because the fontwidth is too wide.
Sorry, something went wrong.
There was a problem hiding this comment.
I agree with that; almost all the test images that changed appear mostly okay before.
Sorry, something went wrong.
|
In general I'm not in favour of this PR, simply because it seems that it creates not enough labels for the general case and the determination of the spacing seems to be rather arbitrary. Adding this either as a different WideSpreadAutoDateLocator or via an argument AutoDateLocator(spread="generous") to the existing one seems to make more sense to me. Else, I would argue that the spreading needs to take into account the actual fontsize (not the one from rcParams) and also the rotation of the labels - but that may be rather difficult, because those are not know before drawtime, right? |
Sorry, something went wrong.
|
I think tick locators are determned at draw time, so thats OK, but you are correct that it should use the actual fontsize of the tick labels, not the one from rcParams! |
Sorry, something went wrong.
|
I think the trouble with estimating the actual size would require the Text objects. Due to the order in which we use the locators in Axis's iter_ticks() there will be no text when we determine the number of ticks, which is the main cause of this issue. Also, any suggestions on retrieving the width of the axis? Rotation: Font size of tick labels: Not enough labels: AutoDateLocator with parameter: I will try to implement DateLocator with this parameter. |
Sorry, something went wrong.
…or.spacing to rcparams' as an option
|
To make some progress and ensure previous image tests are preserved, I added rcParams["autodatelocator.spacing"] and I am using the axis's label for font and axis's figure for figsize. However I do have some concerns: |
Sorry, something went wrong.
|
@shadidsh the width of the axes can be got from ax.get_position(original=False). Its in figure-normal co-ordinates, so you should use a transform to get to inches. |
Sorry, something went wrong.
|
There seem to be several test image changes with imperceptible differences, leading me to think these images should not be changing at all. |
Sorry, something went wrong.
|
I removed the unnecessary images, after changes to the PR I did not check them out properly. The code now uses the axes width transformed from the axes's position. Please note the reason I added the parameter to RcParams is because rotation of label at this point does not seem to be set, thus spacing would be problematic. Any feedback and suggestions would be greatly appreciated, thanks. |
Sorry, something went wrong.
| # bysecond, unused (for microseconds)] | ||
| byranges = [None, 1, 1, 0, 0, 0, None] | ||
|
|
||
| # Required attributes to get width from figure's normal points |
There was a problem hiding this comment.
I think this should all be wrapped in if spacing:
I don't get why you are using getattr for all these. If these attributes don't exist, you might as well error here because you weren't passed an axis...
Sorry, something went wrong.
There was a problem hiding this comment.
If we raise exceptions it would break existing tests using mock classes that might have aaxis attributes as none.
Sorry, something went wrong.
There was a problem hiding this comment.
Which tests? I don't understand what a test would be doing down in here w/o the axes being set (for instance).
Sorry, something went wrong.
There was a problem hiding this comment.
for example test_dates.py::def test_auto_date_locator(), this uses dummy axis to specifically check values returned from autodatelocator. It has a few none axis attributes
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/tests/test_dates.py#L320
Sorry, something went wrong.
There was a problem hiding this comment.
OK, well I'd just check if whichever one of these is None and set spacing=False if that happens
Sorry, something went wrong.
| if label is not None: | ||
| font_ratio = label.get_fontsize() / 10 | ||
| else: | ||
| font_ratio = rcParams['font.size'] / 10 |
There was a problem hiding this comment.
I'm pretty sure the ticks have a fontsize associated with them beyond the label fontsize. THats the fontsize you should querry, and I'm pretty sure it exists.
Sorry, something went wrong.
| byranges[i] = None | ||
| continue | ||
|
|
||
| # Compute at runtime the size of date label with given format |
There was a problem hiding this comment.
again, this should only happen if spacing is on.
Sorry, something went wrong.
| ((num/interval) * datelen_ratio) <= maxwid) | ||
| if (num <= interval * (self.maxticks[freq] - 1)): | ||
| if (apply_spread): | ||
| break |
There was a problem hiding this comment.
??? I don't understand why you only break if apply_spread=True here.
Sorry, something went wrong.
There was a problem hiding this comment.
When users have rotated labels we shouldn't apply spread, it applies too much spacing. Unfortunately this is why i added to Rcparams in the first place
Sorry, something went wrong.
There was a problem hiding this comment.
But you need "interval" to be correct for byranges, below.
Sorry, something went wrong.
| #date.autoformatter.second : %H:%M:%S | ||
| #date.autoformatter.microsecond : %M:%S.%f | ||
|
|
||
| #autodatelocator.spacing : tight ## if generous, add extra spacing to avoid overlap, otherwise tight |
There was a problem hiding this comment.
Maybe autodatelocator.generousspacing : False True/False would be a cleaner API?
Sorry, something went wrong.
|
Some comments provided. I'm 50/50 on the PR as a whole. The issue is that most of the time dates on the xaxis are too long. What'll happen here is that there will just be too few ticks. The real solution is making the ticklabels shorter (i.e. #10841) and rotating the ticklabels. |
Sorry, something went wrong.
|
@jklymak Thanks so much for the feedback, when i get the chance I will add the fixes for experience so I am fine if the PR is closed after the update. |
Sorry, something went wrong.
|
@shadidsh thanks so much for the PR. Sorry that it didn't make it in, but it was a good idea. We are curretnly discussing tick-related issues, with an idea to completely overhaul them in 3.0. Now that you have some development experience under your belt, please feel free to contribute to that discussion. @timhoffm is leading it, though for the life of me, I can't remember or find what the issue is. @timhoffm can we open a modern issue, w/ you as the author, to keep track of tick-related things... @shadidsh hopefully we see more of you! Thanks again. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Fix for issue #7712
This PR addresses the overlapping date intervals that can still be found. I noticed PR #8251 just changed the hard coded data table, yet it still resulted in overlaps when dealing with minutely changes. Without changing the data table, I used rcParam's figsize and fontsize to make a conservative estimation of characters that can fit per inch.
Although the solution requires more information I believe this makes it less dependent on future changes to the table. I have modified all image tests required, added coverage, and added to next_api_changes to inform users that image outputs have changed. Thanks in advance for any feedback on this PR.
PR Checklist