Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: adjust tick label location when tick length changes #7119

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 3 commits into from
Sep 16, 2016

Conversation

efiring
Copy link
Member

@efiring efiring commented Sep 15, 2016

  • Add a test

Closes #7114.

@efiring
Copy link
Member Author

efiring commented Sep 15, 2016

I still need to add a test.
The logic in axis.py is pretty hard to follow; some refactoring and renaming is probably in order, but the priority here is to come up with a minimally-invasive bugfix in time for 2.0.

@efiring efiring added this to the 2.0 (style change major release) milestone Sep 15, 2016
@efiring efiring added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Sep 15, 2016
@efiring
Copy link
Member Author

efiring commented Sep 15, 2016

Travis is failing because the original test_tightlayout.test_outward_ticks is incorrect owing to the bug that we are fixing. The bug was masked by the remove_text=True in the test decorator.

Previously, the test was broken by the inclusion of remove_text=True
in the decorator.  With that changed to False, and the images
updated, this test serves double-duty as a test for the bug
in updating tick parameters that is fixed in the present PR.
@NelleV
Copy link
Member

NelleV commented Sep 16, 2016

I have to ask… why was the _translate_tick_kw implemented? You seem to be the main author of this function, so you may remember. It's fairly old.

for line in (self.tick1line, self.tick2line):
line.set_markersize(self._size)
line.set_markeredgewidth(self._width)
# _get_text1_transform uses _pad from apply_tickdir
Copy link
Member

Choose a reason for hiding this comment

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

I think you should add a comment mentioning that apply_tickdir uses self._size to compute the self._pad value, as this was the core of the problem here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a commit to flesh out the comments.

Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

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

That code is tricky :)
I indeed think it needs a bit of refactoring and renaming.

Thanks!

@efiring
Copy link
Member Author

efiring commented Sep 16, 2016

On 2016/09/15 4:16 PM, Nelle Varoquaux wrote:

I have to ask… why was the |_translate_tick_kw| implemented? You seem to
be the main author of this function, so you may remember. It's fairly old.

The problem was that long ago, when the Tick system was designed, it was
given a set of keyword arguments and corresponding attributes that
undoubtedly made sense at the time, but that were not ideal for an
end-user API. When I decided to write a convenience function for
modifying tick parameters, I wanted to give it nicer kwargs,
specifically designed to be suitable--readable and memorable, I
hope--for that function. Therefore I wrote _translate_tick_kw to map
the new kwargs to the old.

For example, this enables tick_params(top=True, labeltop=True)
instead of tick_params(tick2On=True, label2On=True).

Actually it goes beyond that because tick_params can work with xticks,
yticks, or both at the same time; separate functions would have been
needed for x and y if I had stuck with the original kwargs.

@NelleV
Copy link
Member

NelleV commented Sep 16, 2016

I haven't look at the code closely: would it be possible to remove this function and change the kwargs downstream in the code?

@NelleV
Copy link
Member

NelleV commented Sep 16, 2016

I should note that this is way out of the scope of this PR… just wondering for the future.

@efiring
Copy link
Member Author

efiring commented Sep 16, 2016

@NelleV Some amount of translation is still needed to handle the distinction between attributes of all ticks and attributes of x versus y ticks. Apart from that, we have the old backwards-compatibility constraint on the API to worry about.

@tacaswell
Copy link
Member

The first step would be to alias them the other way.

It might be worth considering going the AxisArtist route and just re-implementeding axis + tick, backporting as much of the old API as reasonable, and then making the default class used for the axis + ticks configurable.

@NelleV NelleV merged commit 9563001 into matplotlib:v2.x Sep 16, 2016
@NelleV
Copy link
Member

NelleV commented Sep 16, 2016

Thanks!

@efiring efiring deleted the tick_length_and_labels branch September 16, 2016 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants