python

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

66

486 views

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

  1. # coding: UTF-8
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. left = np.array([1, 2, 3, 4, 5])
  5. height1 = np.array([100, 200, 300, 400, 500])
  6. height2 = np.array([3, 4, 5, 6, 7])
  7. height3 = np.array([4, 5, 6, 7, 8])
  8. height4 = np.array([10, 20, 30, 40, 50])
  9. fig = plt.figure()
  10. bar1 = fig.add_subplot(2, 2, 1)
  11. bar1.bar(left, height1)
  12. bar2 = fig.add_subplot(2, 2, 2)
  13. bar2.bar(left, height2)
  14. bar3 = fig.add_subplot(2, 2, 3)
  15. bar3.bar(left, height3)
  16. bar4 = fig.add_subplot(2, 2, 4)
  17. bar4.bar(left, height4)
  18. plt.show()

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

Page 50 of 69.

前のページ 次のページ



[添付ファイル]


お問い合わせ

プロフィール

すぺぺぺ

自己紹介

本サイトの作成者。
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
ChatGPTで自動プログラム作成に取り組み中。

サイト/ブログ

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

ツイッター

@darkimpact0626