ENH: allow title autopositioning to be turned off - #17127
Conversation
|
ping @tacaswell and @ImportanceOfBeingErnest who had opinions on the previous... |
95d6ca6 to
9bb232b
Compare
| return title.get_text() | ||
|
|
||
| def set_title(self, label, fontdict=None, loc=None, pad=None, **kwargs): | ||
| def set_title(self, label, fontdict=None, loc=None, y=None, pad=None, |
There was a problem hiding this comment.
Can we please make y a keyword only? If not it needs to go after pad.
There was a problem hiding this comment.
made the signature: def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None, **kwargs):
|
I think this is probably the best path forward (modulo input order). I suspect we are going to end up with some degree of un-avoidable breakage, but this gives is a way to get the old behavior back if people need it and does not introduce more implicit behavior. |
161a81b to
6861192
Compare
|
I suppose it was possible someone was explicitly setting y=1 and counting on the repositioning behaviour, but it would be a strange thing to do. |
ca01a53 to
3c55453
Compare
| plt.show() | ||
|
|
||
| ########################################################################### | ||
| # The vertical position is automatically chosen to avoid decorators on the |
There was a problem hiding this comment.
Is „decorators“ a term we commonly use? If not and because of the duplicate meaning with python decorators, I‘d just use „tick labels and axis labels“ instead.
There was a problem hiding this comment.
Well, its used in the constrainedlayout_guide, but I wrote that, so ;-) But it should be "decorations".
We need some word for this other than "ticks, labels, extra legends, annotations, etc etc". and I think "decorations" is a reasonable choice.
3c55453 to
30e05cc
Compare
| if y is None: | ||
| y = rcParams['axes.titley'] | ||
| if y is None: | ||
| y = 1.0 |
There was a problem hiding this comment.
Do you need self._autotitlepos = True here?
There was a problem hiding this comment.
The problem here is that there are really three titles with one interface. So setting self._autotitlepos=True here would allow toggling the automatic behaviour, but that behaviour would also affect other titles. i.e.
ax.set_title('Center', y=1.0)
ax.set_title('Left', loc='left')would turn auto positioning on again for both titles.
I think the current proposed behaviour is if you make it manual, it stays manual, leads to the least unexpected results. We could make it all more complicated, but I really don't envision folks toggling this.
There was a problem hiding this comment.
Ok, that might still confuse someone, but you're right, the alternative would be more problematic because people might want to position the different titles differently.
|
Hmm now that I think about it, if someone manually sets the y value using the text property the title will now still be auto positioned. I guess I still think this is ok. If the user thinks they will twiddle the text property they can set it manually to start as well. |
PR Summary
Closes #16805
Sometimes users do not want auto positioning of the title. i.e. if they set
rcParams['axes.titlepad']=-20they probably meant relative toy=1and do not want the title to float above y=1, which is what we do now..Here allow users to specify
yin theset_titleand provide arcParams['axes.titley']. This defaults to None for auto positioning, but if set to something else autopositioning is turned off.Alternative to #16862
PR Checklist