-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
lib/matplotlib/rcsetup.py
Outdated
@@ -465,6 +465,11 @@ def validate_font_properties(s): | |||
'verbose', | |||
['silent', 'helpful', 'debug', 'debug-annoying']) | |||
|
|||
validate_alignment = ValidateInStrings( |
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.
note to myself. Make this private.
@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? |
lib/matplotlib/tests/test_axes.py
Outdated
@@ -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'], |
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.
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
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.
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 |
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.
Shouldn't there be xtick.alignment
added as well?
lib/matplotlib/rcsetup.py
Outdated
@@ -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], |
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.
This should go in the xtick
section above.
lib/matplotlib/tests/test_axes.py
Outdated
@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 |
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.
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') |
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.
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?
@QuLogic Comments are fixed. |
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. |
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
Note: this pull request supersedes #7970