Repository navigation
Open
Labels
keepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Action
Description
Bug report
Bug summary
Copy Canvas tool seems to have been implemented in v3.0 as in #10446 but is not enabled in Matplotlib 3.0.2 by default. Copy/paste functionality can be restored using plt.rcParams['toolbar'] = 'toolmanager' but creates warnings as in #7404
Code for reproduction
# Paste your code here
# plt.rcParams['toolbar'] = 'toolmanager' #restores copy to clipboard functionality by replacing toolbar2 with toolmanager
x = np.linsapce(1,10); y = np.linspace(1,10)
fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()Actual outcome
Default behavior (no copy/paste functionality, toolbar2)

Setting toolbar to toolmanager (copy/paste functionality, toolmanager). Console warning output shown below when activated

# If applicable, paste the console output here
C:\Users\Alex\Miniconda3\envs\vanilla\lib\site-packages\matplotlib\backend_managers.py:58: UserWarning: Treat the new Tool classes introduced in v1.5 as experimental for now, the API will likely change in version 2.1 and perhaps the rcParam as well
'experimental for now, the API will likely change in ' +
C:\Users\Alex\Miniconda3\envs\vanilla\lib\site-packages\matplotlib\backend_tools.py:79: UserWarning: Treat the new Tool classes introduced in v1.5 as experimental for now, the API will likely change in version 2.1, and some tools might change name
'experimental for now, the API will likely change in ' +
Expected outcome
Pressing ctrl+c or cmd+c should copy figure to clipboard as in #10446 and rcParams documentation by default. It seems that it must be explicitly turned on at the moment
Matplotlib version
- Operating system: Windows 10
- Matplotlib version: 3.0.2, installed via conda (default channel)
- Matplotlib backend (
print(matplotlib.get_backend())): Qt5Agg - Python version: 3.7.1
- Jupyter version (if applicable): N/A
- Other libraries:
Metadata
Metadata
Assignees
Labels
keepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Action
Activity
kasanitej commentedon Mar 26, 2019
Hi,
The reason for not default is because of TkAgg, it is still a major backend for matplotlib. Copy+paste is still not configured for Tkinter, until then we have to explicitly force it.
timhoffm commentedon Mar 30, 2019
@kasanitej is that something we would have to do in matplotlib, or is that an issue with Tkinter?
EBenkler commentedon Sep 17, 2019
Probably a stupid question:
Why then not simply enable it by default for all backends except for TkAgg?
Something like
anntzer commentedon Sep 17, 2019
because no agreement has been reached on the toolmanager api yet.
github-actions commentedon Jun 2, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
OpenFoam-User commentedon Aug 9, 2023
Hi,
Any updates on this?
anntzer commentedon Oct 30, 2023
I recently wanted to try this functionality as well (and after trying it I now think it is something that can sometimes be quite practical indeed), so I decided to implement it independently of MEP22; it's at https://github.com/anntzer/mplcopy/blob/main/src/mplcopy.py
Instead of implementing it per-backend I went for the per-OS solution (with a dependency on pywin32 for Windows, although writing a proper C extension or going via ctypes should be "easy", and on xclip for Linux), and took advantage of the figure.hooks rcParam for installation. As a consequence this should(?) work for all backends, including tkagg as well as the notebook backends (not that I tried...).
As always I don't really mind if this stays as third-party standalone or if someone wants to try to PR this into core (I personally think it's just fine as it is).
OpenFoam-User commentedon Oct 30, 2023
Thank you for this extension! I have built it, and it works fine on Windows 11.
Could you please update the README.md to add instructions on how to build it and add it to
matplotlibrcfile ?Thank you
anntzer commentedon Oct 30, 2023
The relevant information is described in the module docstring. I am intentionally the whole thing as single-file as possible because I intend extremely limited (edit: essentially no) maintenance for that module, and would rather let users pick up whatever parts of it that work for them.