-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
@@ -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 |
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.
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.
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.
I think that's a valid point, I think above size would be a good location
lib/matplotlib/rcsetup.py
Outdated
@@ -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 |
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.
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
In general, this looks good. In addition to the two suggestions above, maybe this should get a test and a what's new notice? |
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 |
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 |
I have modified the existing test by setting the rcParam explicitly in |
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.
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.
Not quite sure if this should be So, as a quick vote:
|
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.
Looks good to me 👍 Thanks for your first contribution to Matplotlib, hope to see you back!
PR Summary
UTSC student creating pull request for for CSCD01.
Added new rcparam to set default axes title location requested in #9682.
PR Checklist