Skip to content

clone more legend settings when regenerating in Qt figure options dialog #4

@jennjwang

Description

@jennjwang

Bug report

xref https://stackoverflow.com/questions/62602933/matplotlib-navigation-toolbar-resets-legendstyle

The logic to regenerate the legend in the Qt figure option window discards most of the custom state set on the legend.

Bug summary

The logic that regenerate the legend pulls only ncols and if the legend is draggable

https://github.com/matplotlib/matplotlib/blob/e73d4e056588abc201335d8a491fd9cb37d4c296/lib/matplotlib/backends/qt_editor/figureoptions.py#L237-L246

but nothing else.

Code for reproduction

import matplotlib .pyplot as plt
fig, ax = plt.subplots()
ax.plot(range(5), label='a')
ax.plot(range(3)[::-1], label='b')
ax.legend(bbox_to_anchor=(0,1.02,1,0.2), loc="lower left", mode="expand", borderaxespad=0, ncol=3)
plt.show()

open the figure options, tick "(Re)-generate legend" and hit OK or apply

Actual outcome

The legend settings are discarded when the figure is re-generated

Expected outcome

The bbox_to_anchor, loc,... settings to be re-used.

Matplotlib version

  • Operating system: any
  • Matplotlib version: 3.2+
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg (any Qt5 backend)
  • Python version: Any

installed from source

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions