Add option to rotate labels in a pie chart (#2304)#8217
Add option to rotate labels in a pie chart (#2304)#8217NelleV merged 5 commits intomatplotlib:masterfrom
Conversation
phobson
left a comment
There was a problem hiding this comment.
Thanks for the thorough and well-tested PR!
lib/matplotlib/axes/_axes.py
Outdated
| label_alignment = xt > 0 and 'left' or 'right' | ||
| label_rotation = 'horizontal' | ||
| if labelrotate: | ||
| label_rotation = thetamd + (0 if xt > 0 else 180) |
There was a problem hiding this comment.
Instead of using thetamd I think it would be better to just use np.rad2deg(thetam)
|
This looks really good, thanks for the PR! I think |
|
Just noticed vertical alignment needs to be updated as well, it should be fixed now. |
dstansby
left a comment
There was a problem hiding this comment.
This looks good now, thanks for the work! I will merge if/when travis and appveyor tests pass.
|
It looks like there's a PEP8 violation: https://travis-ci.org/matplotlib/matplotlib/jobs/208805540#L1676 - other than that the travis tests seem fine. |
|
Thanks! |
|
Ugh, sorry, I should have noticed that - thanks for pointing it out. I'll fix that myself and merge this pull request when I've done that. |
| def pie(x, explode=None, labels=None, colors=None, autopct=None, | ||
| pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=None, | ||
| radius=None, counterclock=True, wedgeprops=None, textprops=None, | ||
| center=(0, 0), frame=False, hold=None, data=None): |
There was a problem hiding this comment.
Yes, the changes on this file are generated by boilerplate.py.
There was a problem hiding this comment.
As long as you haven't manually updated this file, it's all good :)
| wedgeprops=None, textprops=None, center=(0, 0), | ||
| frame=False): | ||
| frame=False, rotatelabels=False): | ||
| r""" |
There was a problem hiding this comment.
Do you mind converting this docstring into numpydoc? It will make it much more readable.
There was a problem hiding this comment.
I would be happy to, do you want me to create a separate issue for that?
There was a problem hiding this comment.
Yes, let's do this. I am going to merge this PR straight away, as everything is fine!
|
Thanks for the patch! |
Fixes #2304
I add the flag
labelrotate=True, it should fix the problem in most cases.For pie chart with too many sections, I think using leader lines should be a better solution.