Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add framealpha argument for legend #1626

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 2 commits into from
Jan 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion examples/pylab_examples/legend_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def fig_1():
figure(1)
t = arange(0, 40.0 * pi, 0.1)
l, = plot(t, 100*sin(t), 'r', label='sine')
legend()
legend(framealpha=0.5)

def fig_2():
figure(2)
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4448,6 +4448,9 @@ def legend(self, *args, **kwargs):
If *True*, draw a shadow behind legend. If *None*,
use rc settings.

*framealpha*: [*None* | float]
If not None, alpha channel for legend frame. Default *None*.

*ncol* : integer
number of columns. default is 1

Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def __init__(self, parent, handles, labels,
# box, none use rc
shadow=None,
title=None, # set a title for the legend

framealpha=None, # set frame alpha

bbox_to_anchor=None, # bbox that the legend will be anchored.
bbox_transform=None, # transform for the bbox
frameon=None, # draw frame
Expand Down Expand Up @@ -195,6 +198,7 @@ def __init__(self, parent, handles, labels,
fancybox if True, draw a frame with a round fancybox.
If None, use rc
shadow if True, draw a shadow behind legend
framealpha If not None, alpha channel for the frame.
ncol number of columns
borderpad the fractional whitespace inside the legend border
labelspacing the vertical space between the legend entries
Expand Down Expand Up @@ -384,6 +388,9 @@ def __init__(self, parent, handles, labels,
# init with null renderer
self._init_legend_box(handles, labels)

if framealpha is not None:
self.get_frame().set_alpha(framealpha)

self._loc = loc

self.set_title(title)
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading