python

しょっちゅう忘れることを書いておく。

33

200 views

matplotlibで1画面を4分割してグラフを表示する

# coding: UTF-8
import matplotlib.pyplot as plt
import numpy as np

left = np.array([1, 2, 3, 4, 5])
height1 = np.array([100, 200, 300, 400, 500])
height2 = np.array([3, 4, 5, 6, 7])
height3 = np.array([4, 5, 6, 7, 8])
height4 = np.array([10, 20, 30, 40, 50])

fig = plt.figure()
bar1 = fig.add_subplot(2, 2, 1)
bar1.bar(left, height1)

bar2 = fig.add_subplot(2, 2, 2)
bar2.bar(left, height2)

bar3 = fig.add_subplot(2, 2, 3)
bar3.bar(left, height3)

bar4 = fig.add_subplot(2, 2, 4)
bar4.bar(left, height4)

plt.show()

subplotの第一引数は横に2分割、第二引数は縦に二分割、第三引数は何番目に表示するかを表す。

Page 50 of 56.

前のページ 次のページ



[添付ファイル]


お問い合わせ

プロフィール

マッスル

自己紹介

本サイトの作成者。
趣味:プログラム/水耕栽培/仮想通貨/激辛好き
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
仮想通貨はNEMが好き。
水耕栽培は激辛好きが高じて、キャロライナ・リーパーの栽培にチャレンジ中。

サイト/ブログ

https://www.osumoi-stdio.com/pyarticle/

ツイッター

@darkimpact0626