1
2

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 > 2つのグラフを表示する > plt.figure() / plt.subplot()

Last updated at Posted at 2017-01-16
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

2つの画像を並べて表示しようとしている。

plt.figure使用

Python 機械学習プログラミング by Sebastian Raschkaら

in100_out100.ipynb
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(123)
fig1,fig2 = plt.figure(1), plt.figure(2)
plt.figure(1)
plt.plot(np.random.rand(100))
plt.figure(2)
plt.scatter(np.random.rand(100), np.random.rand(100))
plt.show()

グラフが縦に並んだ。

qiita.png

plt.subplot()使用

plt.subplot()というのがあったことを思い出した。

in100_out100.ipynb
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(123)
fig1 = plt.figure(1)
plt.subplot(221)
plt.plot(np.random.rand(100))
plt.subplot(222)
plt.scatter(np.random.rand(100), np.random.rand(100))
plt.show()

2x2の配置において、1,2の場所に置いてみた (1始まりのインデックス)。

qiita.png

link

以下に良い記事がありました。
http://qiita.com/supersaiakujin/items/543053ca4610437112df

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?