diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 0c7893b81977..49c17895029d 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2884,6 +2884,7 @@ class NavigationToolbar2: ('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'), (None, None, None, None), ('Save', 'Save the figure', 'filesave', 'save_figure'), + ('Copy', 'Copy to clipboard', 'copyfigure', 'copy_figure'), ) def __init__(self, canvas): @@ -3239,6 +3240,10 @@ def configure_subplots(self, *args): manager.show() return self.subplot_tool + def copy_figure(self, *args): + """Copy the current figure.""" + raise NotImplementedError + def save_figure(self, *args): """Save the current figure.""" raise NotImplementedError diff --git a/lib/matplotlib/backends/backend_qt.py b/lib/matplotlib/backends/backend_qt.py index 364e4a509ad6..8777a04bd924 100644 --- a/lib/matplotlib/backends/backend_qt.py +++ b/lib/matplotlib/backends/backend_qt.py @@ -752,6 +752,10 @@ def configure_subplots(self): self._subplot_dialog.show() return self._subplot_dialog + def copy_figure(self, *args): + pixmap = self.canvas.grab() + qApp.clipboard().setPixmap(pixmap) + def save_figure(self, *args): filetypes = self.canvas.get_supported_filetypes_grouped() sorted_filetypes = sorted(filetypes.items()) diff --git a/lib/matplotlib/mpl-data/images/copyfigure.png b/lib/matplotlib/mpl-data/images/copyfigure.png new file mode 100644 index 000000000000..6026854d1c3d Binary files /dev/null and b/lib/matplotlib/mpl-data/images/copyfigure.png differ
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: