8000 If Legend shadow=True set framealpha=1 if not passed explicitly instead of consulting rcParams by s0vereign · Pull Request #8988 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

If Legend shadow=True set framealpha=1 if not passed explicitly instead of consulting rcParams #8988

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 6 commits into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
alpha of legend is now set with set_alpha method and thus changed
the test to use the get_alpha method
  • Loading branch information
s0vereign committed Aug 4, 2017
commit a030a8d538951ad0d622386d6ff7dba1af2c81e4
4 changes: 2 additions & 2 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ def __init__(self, parent, handles, labels,
# If shadow is activated use framealpha if not
Copy link
Member

Choose a reason for hiding this comment

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

This comment is perfect here! Can you also add a note about this to the docstring at https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_axes.py#L298 ?

Copy link
Contributor Author
@s0vereign s0vereign Aug 9, 2017

Choose a reason for hiding this comment

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

Always glad to help. 👍

I would put it into the doc of framealpha:

framealpha : None or float

to make clear that if shadow is activated and framealpha is None it will set the value to be 1 instead of taking it from legend.framealpha :data:rcParam<matplotlib.rcParams>.

Should I also add something to

shadow : None or bool
?

Copy link
Member

Choose a reason for hiding this comment

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

To both? The goal is to make sure users are not confused / can un-confuse them selves easily. Putting it in shadow warns someone using it that it might affect other parts and someone who is having issues with the default framalpha being ignored might go check it's docstring.

# explicitly passed. See Issue 8943
if framealpha is None:
if shadow is True:
< 8000 /td> self.framealpha = 1
if shadow:
self.get_frame().set_alpha(1)
else:
self.get_frame().set_alpha(rcParams["legend.framealpha"])
Copy link
Member

Choose a reason for hiding this comment

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

why are there two ways of setting framealpha? I would stick with the self.get_frame().set_alpha() way, unless we should change it everywhere to self.framealpha. Also, we don't need shadow is True, it can be just shadow.

Copy link
Contributor Author
@s0vereign s0vereign Aug 4, 2017

Choose a reason for hiding this comment

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

Alright will change both lines as proposed.

else:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,4 @@ def test_shadow_framealpha():
fig, ax = plt.subplots()
ax.plot(range(100), label="test")
leg = ax.legend(shadow=True, facecolor='w')
assert leg.framealpha == 1
assert leg.get_frame().get_alpha() == 1
Copy link
Member

Choose a reason for hiding this comment

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

This will need a new (empty) line at the end to assuage pep8

0