Jupyter Notebook:自动保存所有图像 [英] Jupyter Notebook: automatically saves all images

查看:202
本文介绍了Jupyter Notebook:自动保存所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Jupyter笔记本中的大多数图像, https://cdn.rawgit.com/cqcn1991/Wind-Speed-Analysis/master/output_HTML/marham.html

I need most images in my jupyter notebook, https://cdn.rawgit.com/cqcn1991/Wind-Speed-Analysis/master/output_HTML/marham.html

问题是太多了,并且通过命令或手动将它们一一保存非常耗时.

The problem is that there are too many, and saving them one by one, by command or manually is very time-consuming.

是否可以自动将所有图像保存在笔记本中?

Is there a way to automatically save all images in a notebook?

例如,也许我可以做出魔术命令

For example, maybe I can make a magic command

%matplotlib autosave

,图像将被顺序保存,分别在笔记本的目录中命名为1.pic,2.pic....

and the images would be saved sequentially, named as 1.pic, 2.pic ... in the dir of the notebook.

此外,发布的推荐图像格式是什么?如果可以编辑图像,更改样式等,那就太好了.

Addtionally, what is the recommand image format for publishing? It would be good if the image could be edit, change styles, etc.

推荐答案

您可以使用转换 Jupyter选项.语法是

You can use the convert option of Jupyter. The syntax is

jupyter nbconvert --to FORMAT notebook.ipynb

默认值为html,因此它将图像转换为PNG文件.您还可以使用LaTeX转换

The default is html, so it will convert your images to PNG files. You can also use a LaTeX conversion

jupyter nbconvert --to latex notebook.ipynb

或者,您可以使用菜单 File>>下载为,然后在其中使用Markdown,重组文本或LaTeX.

Alternatively, you can use the menu File>>Download as, and use Markdown, reSTructured Text or LaTeX there.

关于发布格式,取决于您要查找的期刊.我的建议是在以后要编辑时将图像导出为SVG.Inkscape可以用于此目的),并且可以嵌入LibreOffice中.当您希望它们准备就绪时,请使用PDF.对于笔记本中的图形类型,矢量图形通常更好.如果您打算使用MS Word,则可能需要将图形从SVG转换为EMF,作为中间步骤.

Regarding the format for publication, it depends on the journal you're aiming. My suggestion would be to export your images as SVG when you want to edit later. Inkscape can be used for this purpose), and they can be embedded in LibreOffice. Use PDF when you want them ready to go. Vector graphics are generally better for the type of graphics in your notebook. If you're planning to use MS Word, then you might want to convert the graphics from SVG to EMF as an intermediate step.

这篇关于Jupyter Notebook:自动保存所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆