2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【小ネタ】Jupyterでmatplotlibのグラフを一括で保存する方法

Posted at

はじめに

matplotlibのグラフを1つ1つfigsaveしないで、一括で保存する方法についてです。
JupyterをMarkdownで保存するだけです。グラフの保存形式はpngになります。

方法

  1. Jupyterをmarkdownで保存する。"File" -> "Export Notebook As..." -> "Export Notebook to Markdown"
  2. zipで保存されるので解凍する。

結果

保存されたグラフは、同じpng形式でもmatplotlibのsavefig("*.png")を使ったものと違うものになります。

  1. figsave("a.png")
    a.png

  2. Markdownで保存
    output_2_0.png

白背景でブラウザから見ただけではわからないので、茶色の背景にグラフを貼ったものを掲示します。

  1. figsave("a.png")
    figsave.png

  2. Markdownで保存
    markdown.png

figsaveでも同じように透過させたい場合は、fig.patch.set_alpha(0)とすれば良いそうです。

参考
Matplotlib で図の余白のみを透明にする

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?