Skip to content

FIX label vertical alignment can now be specified #8081

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
Feb 21, 2017
Merged

FIX label vertical alignment can now be specified #8081

merged 3 commits into from
Feb 21, 2017

Conversation

NelleV
Copy link
Member

@NelleV NelleV commented Feb 15, 2017

This patch adds a new rcParams allowing to set label vertical alignment. The
sole reason for the existance of this new parameter is to allow user to reset
the style to before 2.0 for testing purposes.

This patch provides a fix to a very pick backward compatibility break. Unfortunately, the
patch that introduces this break also regenerated the test images. This leads to the introduction of a private _test_class stylesheet, corresponding to our current test suite, and a classic stylesheet which is backward compatible.

refs #7905

TODO

  • Document this new parameter
  • add the x equivalent for consistency.

Note: this pull request supersedes #7970

@NelleV NelleV added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Feb 15, 2017
@NelleV NelleV added this to the 2.0.1 (next bug fix release) milestone Feb 15, 2017
@@ -465,6 +465,11 @@ def validate_font_properties(s):
'verbose',
['silent', 'helpful', 'debug', 'debug-annoying'])

validate_alignment = ValidateInStrings(
Copy link
Member Author

Choose a reason for hiding this comment

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

note to myself. Make this private.

@NelleV
Copy link
Member Author

NelleV commented Feb 15, 2017

@tacaswell I am having second thoughts about the API here. There are two possible alignments (horizontal and vertical). Should I rename the rcParams to help identify which of the two alignments we are talking about?

@@ -1143,6 +1143,15 @@ def test_bar_tick_label_multiple():
ax.bar([1, 2.5], [1, 2], width=[0.2, 0.5], tick_label=['a', 'b'],
align='center')

@image_comparison(baseline_images=['bar_tick_label_multiple_old_alignment'],
Copy link
Contributor

Choose a reason for hiding this comment

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

bar_tick_label_multiple_old_label_alignment (cf. the baseline image name)?

This patch adds two new rcParams allowing to set label alignment. The sole
reason for the existance of these new parameters is to allow user to reset the
style to before 2.0 for testing purposes. More specifically, ytick horizontal
alignement was changed in a non backward compatible way. xtick vertical
alignement was added for API consistency.

closes #7905
This allows the public classic stylesheet to be 'more' backward compatible
@NelleV NelleV changed the title [WIP] FIX label vertical alignment can now be specified [MRG] FIX label vertical alignment can now be specified Feb 15, 2017
Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

A few small tweaks, and of course, whether to split vertical/horizontal is still in question.

@@ -271,6 +271,7 @@ ytick.major.left : True # draw y axis left major ticks
ytick.major.right : True # draw y axis right major ticks
ytick.minor.left : True # draw y axis left minor ticks
ytick.minor.right : True # draw y axis right minor ticks
ytick.alignment : center
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there be xtick.alignment added as well?

@@ -1214,6 +1219,9 @@ def validate_animation_writer_path(p):
# fontsize of the ytick labels
'ytick.labelsize': ['medium', validate_fontsize],
'ytick.direction': ['out', six.text_type], # direction of yticks
'ytick.alignment': ["center_baseline", _validate_alignment],
'xtick.alignment': ["center", _validate_alignment],
Copy link
Member

Choose a reason for hiding this comment

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

This should go in the xtick section above.

@image_comparison(baseline_images=['bar_tick_label_multiple_old_label_alignment'],
extensions=['png'])
def test_bar_tick_label_multiple_old_alignment():
# From 2516: plot bar with array of string labels for x axis
Copy link
Member

Choose a reason for hiding this comment

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

This test doesn't really have anything to do with #2516.

@@ -78,7 +78,7 @@ def create_figure():


# test compiling a figure to pdf with xelatex
@cleanup(style='classic')
@cleanup(style='_classic_test')
Copy link
Member

Choose a reason for hiding this comment

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

The tests in this file don't actually use classic, as noted in the pytest conversion; maybe just set them to default now to reflect what's really going on?

@NelleV
Copy link
Member Author

NelleV commented Feb 18, 2017

@QuLogic Comments are fixed.

@tacaswell
Copy link
Member

I see the case for making it 'ytick.valignment' and 'xtick.halignment', however it adds a bit more verbosity, I don't see the use-case for tweaking the other direction (for one thing I think it would break all of the layout logic), and it breaks a nice symmetry between xtick/ytick.

I am 👍 for this going in as-is, and would not protest if the names were changed to be more explicit about what direction they were affecting.

@tacaswell tacaswell changed the title [MRG] FIX label vertical alignment can now be specified [MRG+1] FIX label vertical alignment can now be specified Feb 20, 2017
@QuLogic QuLogic changed the title [MRG+1] FIX label vertical alignment can now be specified FIX label vertical alignment can now be specified Feb 21, 2017
@QuLogic QuLogic merged commit 03e540f into matplotlib:v2.0.x Feb 21, 2017
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