-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make legend title fontsize obey fontsize kwarg by default #9731
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
As the issue [matplotlib#8699](matplotlib#8699) from long time ago stats, I often found this annoying. Seems like nobody is against this idea, and it is a really simple modification. So I'm pulling a request.
Thanks for the PR. Seems reasonable to me. To get this to pass, you'll (unfortunately) need to update some of the |
I'll find some time to see what I can. |
You could alternatively add a fontsize argument to the legend entries on the failing tests to match the test image sizes. That would be easier on the repository size. |
@jklymak Sorry for the delay. Now I'm planning to complete this. But I'm new to this. Can you help me out? If I understands right, there are a few images failed in the tests due to the font size of legend title. And by what you say lg = legend(...)
lg.get_title().set_fontsize(10) Am I guessing right? Would you please explain a little? I'm really new to this. Now I'm actually starting from reading The Matplotlib Developers’ Guide. Any help would be appreciated. |
Set the fontsize of legend title back to 10, in order to pass thhose tests.
Why would it be necessary to set the fontsize in the tests? That would mean that this is a breaking change. I would have figured that this should only fix the situation where fontsize was explicitly specified as a keyword argument? In which case, we would need a test that demonstrated that that works now. |
Yes, I'm confused now. There is a bunch of fontsize handling stuff above this. Why is it wrong and why don't you fix up there? Certainly if you have to grab the title fontsize after instantiation there is something awry. I think whats happening is the legend title is set to whatever the legend fontsize is perfectly reasonable.... |
Oh, OK, I see, it wasn't respecting the legend fontsize or the legend font properties. I'm not clear on what |
@WeatherGod, You were right, by this pull request, I just want the fontsize of legend title to obay the fontsize kwarg of Please anyone give me some instructions on what to do next. Or just make this right (much easier than teaching me to do it). |
Maybe the default fontsize is 12, let me see if this passes.
I think @WeatherGod point is that the legend title's font properties are set by the axes font properties. The logic is that the legend font properties are for inside the legend, and the title is outside. If you want to change the behaviour thats a bigger discussion. I appologize if I mislead you above. I thought that the legend's title font properties weren't controllable at all. |
@jklymak. Before this, the fontsize of legend item labels is 'large'. And the legend title doesn't pick this as its own size, so maybe After another looking, maybe I picked a wrong version of As your question "what is better, to default to the rest of legend or default to the rest of the axes". I think default to the legend is more sensible. And besides that, it makes more sense that |
@WeatherGod, So these falls to 2 questions:
|
There is merit to that argument, but as @WeatherGod says, its a "breaking change" in that people who were counting on the old behaviour will be discomfited by the new behaviour. So, it needs a consensus that the breakage is acceptable. |
I think for 3.0 we could consider adding this kwarg again. @gepcel did you manage to set up a development environment, or did you want someone else to take this over? |
@jklymak It would be better if someone take this over. I had the development evvironment, but lost it long time ago during the os reinstallation. And this may need some more discussion. It's not uncommon that people might need the fontsize of legend title larger than that of legend items. It would be better to have a convenient way to make this happen without make things complicated. Since the matplotlib is some kind of foundation of many other tools, it need to accomplish so many features, convenient or not. But matplotlib is also used a lot to quickly plot figures in day to day data analyse works. For this, it would be better that the workflow is more intuitive and convenient. Thanks. |
If its OK, I'll just push to your branch to keep this history. I still think this change is reasonable, and I think sticking it in 3.0 should be fine. |
@jklymak, Do what ever you want. Anything I can help, please let me know. |
@gepcel Thanks so much for your work on this. This approach makes some sense, but is a breaking change. I've proposed an alternate at #10715 that is not a breaking change. i.e it will keep the old behaviour by default, but allow users to set the legend title to a different fontsize if they wish. I hope this is OK w/ you and would suit your needs. I'll keep this open in the case that it does not. |
As the issue #8699 from long time ago stats, I often found this annoying. Seems like nobody is against this idea, and it is a really simple modification. So I'm pulling a request.
PR Summary
PR Checklist