You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow copying an image result from Python Interactive window #1470
Extension version (available under the Extensions sidebar): 2018.12.1
OS and version: Ubuntu 18.04
Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.7.2
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
Relevant/affected Python packages and their versions: None
Expected behaviour
It'd be great if Python plots within the IDE could be copied to the clipboard. I'd expect right-click to show a menu with "Copy" as an option, for example.
Copying pasting quick plots into Slack/e-mail is super convenient for sharing intermediate results with colleagues.
Actual behaviour
Copying code from Python Interactive works (including rich formatting), but copying images does not. Right-clicking on the image does not show a menu. Selecting the image as part of the surrounding code does not include the image.
Workaround: Take screenshot, paste into image editor, crop, copy-paste the crop, close image editor.
Reacted by Wei Zhang, David Waterworth, Yoni Chechik, gerwang, Idan Pazi, Taha Yassine, Dan Brown, Ansh Khurana, Patrick Norman, Leo Ferres and 34 more
Thanks Ian Huff (@IanMatthewHuff). I tried more ideas due to your comment, and you're right that I can paste into GSuite (Gmail, GDocs). It still doesn't work for Slack (Windows, Linux) or Word (Windows), but having it work for GSuite is already very helpful -- thanks!
Summary of current situation:
Copy action from IPython Interactive
Gmail
GDoc
Slack
Word
Drag image from one window to the other
Works
Works
No
No
Select image as part of text, then Ctrl+C
Works
Works
No
No
Right click on image, select "Copy"
No
No
No
No
Reacted by Ryan Stoddard, Anugrah Andisetiawan and Werner
Andrew Delong (@andrewdelong) Thanks for checking that out for us. Glad that you are (somewhat) unblocked for now. I'll look into the pasting issues as I'm surprised that Word in particular doesn't work. We also want to get a context menu in here for this so it's more discoverable.
I was just playing with this a bit myself and I was able to paste into Word, but it was odd. Some sections would paste and others would not and getting selection correct was tricky as well. Will have to look into this more as a whole "copy / paste correctly" meta issue.
Somewhat related to this is the 'theme' for the plot. We force dark on dark themes, but the user may wish to save/copy the plot as a different theme. See some of the discussion in microsoft/vscode-python#4009
Ian Huff (@IanMatthewHuff) is it possible that selection support for output images was removed in the last few versions? I've got extension version 2019.3.6558 and clicking on output images does nothing. Neither does pressing ctrl-c. :(
This is my first time trying VSCode for Jupyter notebooks and I immediately ran into this problem since my primary way of getting images out of notebooks and into emails / presentations is copy&pasting them.
Also I'll need to find a way to get rid of the dark theme on plots, but that's another google.
Hey Markus Stöger (@stmax82) . Currently the support that we do / did have for selecting output images is just based on what we get by default for being in a vscode hosted webview. I don't believe that it should have changed recently, but since this is not something that we have directly added we don't have any specific tests around it. We have the issue referenced above for getting this support fully in and solid.
For what it's worth I just poked around a bit myself. If I did a drag selection over the matplotlib graph (so that I could see a selection around it) I was able to ctrl-c it and paste it into word. Sorry that we don't have this better supported yet, but does that work for you as a workaround?
Ian Huff (@IanMatthewHuff) looks like the trick is selecting the image by dragging the mouse over it - not clicking on it (like I tried before). But still, not sure what I'm doing wrong, this is what I get:
Selection in VS Code:
Result in Word:
Anyway, I can already move some notebooks over to VS Code where I don't need to export the plots and keep the rest in jupyter for a while.
Sorry I'm not able to repro that odd looking box in your copy result. I think that might be how the code input box that use at the bottom to enter new code is coming out in a copy operation. I think that the best thing we can say for now is that this issue is open and on our radar to make sure that we have a good copy story.
Being able to alter the appearance of images (matplotlib themes) regardless of the VS Code theme would be useful. I also think being able to easily copy and/or export the images would be useful.
I see a button to "Export to different formats" but it doesn't do anything when I click on it.
Being able to alter the appearance of images (matplotlib themes) regardless of the VS Code theme would be useful
I don't think that will be coming anytime soon. We don't do the plotting ourselves (it's handled by Jupyter) and in order to generate an image in a different theme, we'd have to rerun the plot code.
It would be very useful to get this feature. I ended using the Snipping Tool as a workaround, which is almost as fast as being able to CTRL+C in VS Code.
I'm on MacOS. I was always able to Copy / Paste image results from the Python interactive window by highlighting/selecting the graphic with the mouse and pressing CTRL+C. However, this functionality seems to have broken in the 1.60 update. I can click+drag the image result into some applications (e.g. an outlook email), but that doesn't work in some other applications (e.g. MS Teams).
I didn't want to create a new issue, but it appears some of the functionality discussed herein is further broken in the new vs code notebooks. Also, my main way of using plots before, dragging them out of vs code directly into powerpoint, no longer works. I must drag them into a windows explorer folder and then into powerpoint.
Reacted by Mikhail Belvederskiy, MartOfTheNorth, Marie-anneMawhin, Saeejith Nair, Ozgun Sakalli, oxygen dioxide, Bakary N'tji Diallo, Ben Saunders, Jason Brodsky, Mateus Marcuzzo and 15 more
Activity
IanMatthewHuff commentedon Jan 24, 2019
Selecting and "ctrl-c" on the plot in the Interactive window will copy the image out. Though we don't yet have a context menu support for this.
andrewdelong commentedon Jan 25, 2019
Thanks Ian Huff (@IanMatthewHuff). I tried more ideas due to your comment, and you're right that I can paste into GSuite (Gmail, GDocs). It still doesn't work for Slack (Windows, Linux) or Word (Windows), but having it work for GSuite is already very helpful -- thanks!
Summary of current situation:
IanMatthewHuff commentedon Jan 25, 2019
Andrew Delong (@andrewdelong) Thanks for checking that out for us. Glad that you are (somewhat) unblocked for now. I'll look into the pasting issues as I'm surprised that Word in particular doesn't work. We also want to get a context menu in here for this so it's more discoverable.
IanMatthewHuff commentedon Jan 25, 2019
I was just playing with this a bit myself and I was able to paste into Word, but it was odd. Some sections would paste and others would not and getting selection correct was tricky as well. Will have to look into this more as a whole "copy / paste correctly" meta issue.
IanMatthewHuff commentedon Feb 28, 2019
https://stackoverflow.com/questions/54930530/how-to-save-images-from-python-interactive-tab-in-microsoft-visual-studio-code/54930957#54930957
SO issue. In addition to Copy have a save to file button?
rchiodo commentedon Mar 5, 2019
Somewhat related to this is the 'theme' for the plot. We force dark on dark themes, but the user may wish to save/copy the plot as a different theme. See some of the discussion in microsoft/vscode-python#4009
stmax82 commentedon Apr 15, 2019
Ian Huff (@IanMatthewHuff) is it possible that selection support for output images was removed in the last few versions? I've got extension version 2019.3.6558 and clicking on output images does nothing. Neither does pressing ctrl-c. :(
This is my first time trying VSCode for Jupyter notebooks and I immediately ran into this problem since my primary way of getting images out of notebooks and into emails / presentations is copy&pasting them.
Also I'll need to find a way to get rid of the dark theme on plots, but that's another google.
IanMatthewHuff commentedon Apr 17, 2019
Hey Markus Stöger (@stmax82) . Currently the support that we do / did have for selecting output images is just based on what we get by default for being in a vscode hosted webview. I don't believe that it should have changed recently, but since this is not something that we have directly added we don't have any specific tests around it. We have the issue referenced above for getting this support fully in and solid.
For what it's worth I just poked around a bit myself. If I did a drag selection over the matplotlib graph (so that I could see a selection around it) I was able to ctrl-c it and paste it into word. Sorry that we don't have this better supported yet, but does that work for you as a workaround?
stmax82 commentedon Apr 25, 2019
Ian Huff (@IanMatthewHuff) looks like the trick is selecting the image by dragging the mouse over it - not clicking on it (like I tried before). But still, not sure what I'm doing wrong, this is what I get:
Selection in VS Code:
Result in Word:
Anyway, I can already move some notebooks over to VS Code where I don't need to export the plots and keep the rest in jupyter for a while.
IanMatthewHuff commentedon Apr 25, 2019
Sorry I'm not able to repro that odd looking box in your copy result. I think that might be how the code input box that use at the bottom to enter new code is coming out in a copy operation. I think that the best thing we can say for now is that this issue is open and on our radar to make sure that we have a good copy story.
greazer commentedon Jun 6, 2019
Let's support a context menu on images with "Open Viewer" and "Copy".
rchiodo commentedon Jun 11, 2019
This isn't possible without this working:
microsoft/vscode#217
dpsugasa commentedon Sep 6, 2019
Being able to alter the appearance of images (matplotlib themes) regardless of the VS Code theme would be useful. I also think being able to easily copy and/or export the images would be useful.
I see a button to "Export to different formats" but it doesn't do anything when I click on it.
rchiodo commentedon Sep 6, 2019
dpsugasa the export button should allow you to save as PDF/PNG. That was working until this change:
microsoft/vscode-python#7181
Although unless you're on our insider's build, you shouldn't have that change. I've added an issue (https://github.com/microsoft/vscode-python/issues/7257) to fix that before our next release.
In relation to this request:
I don't think that will be coming anytime soon. We don't do the plotting ourselves (it's handled by Jupyter) and in order to generate an image in a different theme, we'd have to rerun the plot code.
alext234 commentedon Oct 17, 2019
It'll be cool if we can copy the image straight from vscode.
20 remaining items
CamilleHamon commentedon Aug 19, 2021
It would be very useful to get this feature. I ended using the Snipping Tool as a workaround, which is almost as fast as being able to CTRL+C in VS Code.
rysb-dev commentedon Sep 3, 2021
I'm on MacOS. I was always able to Copy / Paste image results from the Python interactive window by highlighting/selecting the graphic with the mouse and pressing CTRL+C. However, this functionality seems to have broken in the 1.60 update. I can click+drag the image result into some applications (e.g. an outlook email), but that doesn't work in some other applications (e.g. MS Teams).
ceaza commentedon Sep 10, 2021
For charts, copy CTRL+C not working with 1.60 on windows.
bpops commentedon Sep 13, 2021
I didn't want to create a new issue, but it appears some of the functionality discussed herein is further broken in the new vs code notebooks. Also, my main way of using plots before, dragging them out of vs code directly into powerpoint, no longer works. I must drag them into a windows explorer folder and then into powerpoint.
amunger commentedon Aug 12, 2022
A copy to clipboard feature was added to the renderer in microsoft/vscode#129880