8000 New rcparam to set default axes title location by yeosingng · Pull Request #13802 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

New rcparam to set default axes title location #13802

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 8 commits into from
Apr 11, 2019

Conversation

yeosingng
Copy link
Contributor
@yeosingng yeosingng commented Mar 29, 2019

PR Summary

UTSC student creating pull request for for CSCD01.
Added new rcparam to set default axes title location requested in #9682.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@@ -294,6 +294,7 @@
#axes.grid.axis : both ## which axis the grid should apply to
#axes.grid.which : major ## gridlines at major, minor or both ticks
#axes.titlesize : large ## fontsize of the axes title
#axes.titlelocation : center ## alignment of the title
#axes.titleweight : normal ## font weight of title

Choose a reason for hiding this comment

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

Maybe a very minor point here: I wouldn't put the location in between two parameters which set some font attributes. Maybe rather put it above size or below weight? Also the comment could mention the three possible values of this parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's a valid point, I think above size would be a good location

@@ -1180,6 +1180,7 @@ def _validate_linestyle(ls):

'axes.titlesize': ['large', validate_fontsize], # fontsize of the
# axes title
'axes.titlelocation': ['center', validate_string], # alignment of axes title

Choose a reason for hiding this comment

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

Maybe the validation should already make sure only valid locations are passed? E.g. adding a

validate_titlelocation = ValidateInStrings('axes.titlelocation', ['left', 'center', 'right'])

and using it as

'axes.titlelocation':    ['center', validate_titlelocation],  # alignment of axes title

@ImportanceOfBeingErnest ImportanceOfBeingErnest added this to the v3.2.0 milestone Mar 29, 2019
@ImportanceOfBeingErnest
Copy link
Member

In general, this looks good. In addition to the two suggestions above, maybe this should get a test and a what's new notice?

@yeosingng
Copy link
Contributor Author

I'll work on the suggestions above and a what's new. In terms of testing, what type of test do you suggest for an implementation like this? For title alignment I think there's a test test_title_location_roundtrip() in test_axes.py that may cover the cases. Other than the axes itself, are there any standard tests to add when adding a new rcparam?

@ImportanceOfBeingErnest
Copy link
Member

I think what we want to test is that the location specified by the rcParams is correctly applied to the title. This may sound trivial, but such tests are still useful. It looks like you can simply amend the test_title_location_roundtrip() test with a part similar to the existing one, just with the rcParam in use.

@yeosingng
Copy link
Contributor Author

I have modified the existing test by setting the rcParam explicitly in test_title_location_roundtrip(), and have implemented everything else suggested, which consists of: moving the order of the param, validation for correct values, and a 'what's new' notice.

Copy link
Member
@ImportanceOfBeingErnest ImportanceOfBeingErnest left a comment

Choose a reason for hiding this comment

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

An rc parameter to set the title location has been requested by several users. It seems hence useful to be added. This PR is technically sound and complete.

@timhoffm
Copy link
Member

Not quite sure if this should be axes.titlelocation or axes.titleloc. The former is more clear, while the latter matches the parameter name set_title(loc='...'). Probably axes.titlelocation is still better, but we should make that decision consciously.

So, as a quick vote:

  • 👍 for axes.titlelocation
  • 👎 for axes.titleloc

Copy link
Member
@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍 Thanks for your first contribution to Matplotlib, hope to see you back!

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.

4 participants
0