Skip to content

Copy to Clipboard not Enabled by Default #13595

Open

Description

@awbruch

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)
image

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

# 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:

Activity

  1. kasanitej commented on Mar 26, 2019

    @kasanitej

    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.

  2. timhoffm commented on Mar 30, 2019

    @timhoffm
    Member

    Copy+paste is still not configured for Tkinter

    @kasanitej is that something we would have to do in matplotlib, or is that an issue with Tkinter?

  3. EBenkler commented on Sep 17, 2019

    @EBenkler
    Contributor

    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.

    Probably a stupid question:
    Why then not simply enable it by default for all backends except for TkAgg?
    Something like

    if matplotlib.get_backend() != 'TkAgg':
         plt.rcParams['toolbar'] = 'toolmanager'
    
  4. anntzer commented on Sep 17, 2019

    @anntzer
    Contributor

    because no agreement has been reached on the toolmanager api yet.

  5. github-actions commented on Jun 2, 2023

    @github-actions

    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!

  6. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Jun 2, 2023
  7. OpenFoam-User commented on Aug 9, 2023

    @OpenFoam-User

    Hi,
    Any updates on this?

  8. anntzer commented on Oct 30, 2023

    @anntzer
    Contributor

    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).

  9. OpenFoam-User commented on Oct 30, 2023

    @OpenFoam-User

    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).

    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 matplotlibrc file ?

    Thank you

  10. anntzer commented on Oct 30, 2023

    @anntzer
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions