Open huyiqun opened 8 years ago
On 31/03/16 02:57, huyiqun wrote:
When I use %inline mode to plot something, it is not possible to copy or save the image, but only to view it in atom. Is it possible to add such functionality or what is the best workaround on this? I currently connect a qtconsole to the existing hydrogen kernel, and run the plot code there in order to directly right click for copying and saving. Just wonder if this is by any chance doable in atom.
I think this can be easily done. I'll mark this issue as an enhancement.
Also, a quick related question: when the output is one line, it does not pop up a small window that has option for copying or opening in a file. Can this be changed?
If you click on a one-line bubble, Hydrogen will copy its content to the clipboard.
Which language are you using?
For example in python
with matplotlib
you can do this very easily with plt.savefig('example.pdf')
I'm guessing you're looking for browser style "right-click -> save image"?
I am using python and looking for exactly what @rgbkrk has shown. I know saving to a file would be one option, but just wonder if a temporary copy and paste is possible as I am quite used to such functionality. :)
+1 for this!
what @rgbkrk is suggesting is exactly what I am looking for, as I am running my code on a remote notebook, hence plt.savefig()
would save the file to the remote computer, not on my local machine...
+1!
+1! This feature is critical for efficiency improvement when organizing analytics results
In general it would be great if the plugin would simply allow to save an html copy of the script and the inlined outputs.
+1!
+1
+1
I've labeled this as up-for-grabs
because no one is known to be working on this yet there are lots of +1s. If you want to tackle it, please do.
It looks like the API you'd want to use is the Atom ContextMenuManager, likely scoping it to .output-area img
(or something similar).
if you highlight and run both lines:
plt.plot(data)
plt.savefig(path)
with hydrogen, it will save the .png of the plot in the given path. When i did the above, executing them line by line it did not save the fig.
+1
@rgbkrk Is the transfer of image content to the clipboard a different process than the transfer of text to the clipboard? I.e. is it difficult at all to put onto the clipboard, or is it just not exposed in the UI?
I think it's an Atom thing we have to somehow expose, based on experience with context menus for Electron.
I looked a little into the APIs. It appears that Hydrogen currently uses Atom's clipboard API, which seems to only support writing text and not an image.
Atom's clipboard API seems to be separate from Electron's clipboard API, which does allow for writing an image to the clipboard, but it must be a nativeImage
, which seems to only allow PNG or JPG formats.
I was able to get around this by opening the element inspector, selecting the image element, and copying the dataURI to my browser. So long as you have the <img>
, you should be able to pass its src
into NativeImage.createFromDataUrl
to prep the underlying png for export.
+1
+1 I was very sad to find out that Jupyter didn't have this functionality...
+1 Particularly when working with remote kernels copying images to your clipboard would be tremendously helpful.
I've been using a hacky work around for this when working on a remote kernel (and so savefig
saves the plots on the server).
<img alt src="...
)copy link address
It's really not ideal, but for one-off plots, I find it faster than saving to your remote server and retrieving via scp.
When I use %inline mode to plot something, it is not possible to copy or save the image, but only to view it in atom. Is it possible to add such functionality or what is the best workaround on this? I currently connect a qtconsole to the existing hydrogen kernel, and run the plot code there in order to directly right click for copying and saving. Just wonder if this is by any chance doable in atom.
Also, a quick related question: when the output is one line, it does not pop up a small window that has option for copying or opening in a file. Can this be changed?
Thanks!