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

Skip to content

added properties to legend #30127

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
46 changes: 43 additions & 3 deletions lib/matplotlib/backends/qt_editor/figureoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,49 @@
old_legend = axes.get_legend()
draggable = old_legend._draggable is not None
ncols = old_legend._ncols
new_legend = axes.legend(ncols=ncols)
if new_legend:
new_legend.set_draggable(draggable)
fontsize = old_legend._fontsize
loc = old_legend._loc
title = old_legend.get_title().get_text()
alignment = old_legend.get_alignment()
frameon = old_legend.get_frame_on()
borderpad = old_legend.borderpad
labelspacing = old_legend.labelspacing
handleheight = old_legend.handleheight
handletextpad = old_legend.handletextpad
borderaxespad = old_legend.borderaxespad
columnspacing = old_legend.columnspacing
shadow = old_legend.shadow
markerscale = old_legend.markerscale
numpoints = old_legend.numpoints
scatterpoints = old_legend.scatterpoints
mode = old_legend._mode

Check warning on line 270 in lib/matplotlib/backends/qt_editor/figureoptions.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/backends/qt_editor/figureoptions.py#L255-L270

Added lines #L255 - L270 were not covered by tests
# bbox gets some value even though None is passed in the legend function
# bbox = old_legend.get_bbox_to_anchor()._bbox
new_legend = axes.legend(

Check warning on line 273 in lib/matplotlib/backends/qt_editor/figureoptions.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/backends/qt_editor/figureoptions.py#L273

Added line #L273 was not covered by tests
ncols=ncols,
fontsize=fontsize,
loc=loc,
title=title,
alignment=alignment,
frameon=frameon,
borderpad=borderpad,
labelspacing=labelspacing,
handleheight=handleheight,
handletextpad=handletextpad,
borderaxespad=borderaxespad,
columnspacing=columnspacing,
shadow=shadow,
markerscale=markerscale,
numpoints=numpoints,
scatterpoints=scatterpoints,
mode=mode,
# Uncomment this line if bbox default value figured out
# bbox_to_anchor=bbox
)
# new_legend = deepcopy(old_legend)
# axes.add_artist(new_legend)
if new_legend:
new_legend.set_draggable(draggable)

Check warning on line 297 in lib/matplotlib/backends/qt_editor/figureoptions.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/backends/qt_editor/figureoptions.py#L297

Added line #L297 was not covered by tests

# Redraw
figure = axes.get_figure()
Expand Down
Loading