Skip to content
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

Add smart axis label visibility to wcsaxes #6774

Merged
merged 8 commits into from Jan 23, 2018
Merged

Conversation

Cadair
Copy link
Member

@Cadair Cadair commented Oct 20, 2017

This adds configurable behaviour to wcsaxes so if there are no tick labels drawn on an axis the axis label will not be drawn. This can be configured so that the labels are always drawn or so that they are only drawn if ticks are drawn rather than tick labels.

@wafels @astrofrog

@astropy-bot
Copy link

astropy-bot bot commented Oct 20, 2017

Hi there @Cadair 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃.

Everything looks good from my point of view! 👍

If there are any issues with this message, please report them here.

@@ -44,12 +44,13 @@ def set_visibility_rule(self, value):
if value not in allowed:
raise ValueError("Axis label visiblility rule must be one of{}".format(' / '.join(allowed)))

self._visibility_rule = value
self._visiblility_rule = value
Copy link

Choose a reason for hiding this comment

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

spelling mistake. should be self._visibility_rule = value

@@ -19,6 +19,7 @@ def __init__(self, frame, minpad=1, *args, **kwargs):
self.set_ha('center')
self.set_va('center')
self._minpad = minpad
self._visiblility_rule = 'labels'
Copy link

Choose a reason for hiding this comment

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

spelling mistake - should be self._visibility_rule

self._visiblility_rule = value

def get_visibility_rule(self):
return self._visiblility_rule
Copy link

Choose a reason for hiding this comment

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

Spelling mistake - should be self._visiblility_rule

if value not in allowed:
raise ValueError("Axis label visiblility rule must be one of{}".format(' / '.join(allowed)))

self._visiblility_rule = value
Copy link

Choose a reason for hiding this comment

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

spelling mistake - should be self._visibility_rule

def set_visibility_rule(self, value):
allowed = ['always', 'labels', 'ticks']
if value not in allowed:
raise ValueError("Axis label visiblility rule must be one of{}".format(' / '.join(allowed)))
Copy link

Choose a reason for hiding this comment

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

spelling mistake - should be "visibility"

@Cadair
Copy link
Member Author

Cadair commented Oct 21, 2017

@astrofrog curious the docs fail is a real bug: https://travis-ci.org/astropy/astropy/jobs/290617410#L3451

Which interestingly is not covered by the tests.

@Cadair
Copy link
Member Author

Cadair commented Dec 20, 2017

It passed! @astrofrog can you review this when you get a chance?

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Just a small comment - if we can, let's merge this and include in 3.0

CHANGES.rst Outdated
@@ -195,6 +195,11 @@ astropy.utils
astropy.visualization
^^^^^^^^^^^^^^^^^^^^^

- Added automatic hiding of axes labels when no tick labels are drawn on that
axis. This parameter can be configured with
``WCSAxes.coords[].set_visibility_rule`` so that labels are auto hidden when no
Copy link
Member

Choose a reason for hiding this comment

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

@Cadair: this should be set_axislabel_visibility_rule

Cadair and others added 8 commits January 23, 2018 20:34
This adds logic, and user preference, to determine under what conditions axis
labels are drawn. By default if no tick labels are present the axis label will
not be drawn.
The label position should be calculated based on all the bboxes on that axis not
just the one for the current coord.

This also attempts to fix the axislabels_regression test, but for some
reason the label is still in a different place to before, even though
the current behavior is correct.
Use all the bboxes for all the axes to calculate label position.
@astrofrog astrofrog added Ready-for-final-review 💤 merge-when-ci-passes Do not use: We have auto-merge option now. labels Jan 23, 2018
@bsipocz bsipocz merged commit fe921a6 into astropy:master Jan 23, 2018
@bsipocz
Copy link
Member

bsipocz commented Jan 23, 2018

Thanks @Cadair!

Copy link
Member

@eteq eteq left a comment

Choose a reason for hiding this comment

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

I'm also 👍 to letting this go into 3.0

@@ -467,6 +467,10 @@ astropy.visualization
``WCSPixel2WorldTransform`` classes by setting ``has_inverse`` to ``True``.
In order to implement a unit test, also implement the equality comparison
operator for both classes. [#6531]
- Added automatic hiding of axes labels when no tick labels are drawn on that
Copy link
Member

Choose a reason for hiding this comment

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

Space was missing here...

Copy link
Member

@eteq eteq Jan 24, 2018

Choose a reason for hiding this comment

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

FYI, I fixed this directly in master (2ece61c) since it's dead trivial and this got merged already

bsipocz added a commit that referenced this pull request Jan 24, 2018
Add smart axis label visibility to wcsaxes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants