0
0

More than 3 years have passed since last update.

僕のmatplotlib(Python)

Last updated at Posted at 2019-12-17

自分用のまとめ
随時更新
自分が使った、調べたコマンドを記載
自分がわかればいいからところどころ用語が間違ってるかも

!見方

#コマンド
    #引数のオプションの説明

モジュール読み込み

import matplotlib as mpl

頻出操作

図のインスタンス作成

#インスタンス作成
fig = plt.figure()
    figsize=(x,y) #縦横のサイズを指定
    dpi= #画質

#複数の地図を作成
ax1 = fig.add_subplot()
    #第一引数:行
    #第二引数:列
    #第三引数:場所

棒グラフ

グリッド線や、背景色等は後述のヒストグラムと同じ項目で設定可能

ax1.bar()
    #第一引数:棒の幅のリスト
    #第二引数:棒の高さのリスト
    tick_label= #各棒のラベル

ヒストグラム

ヒストグラムの返り値は少し特殊で以下の感じ
n:X軸のデータ
bins:Y軸のデータ
paches:各棒のオブジェクト群

n, bins, patches = ax1.hist()
    #引数は生データの配列
    bins= 棒の数
    color= #配列で色を指定

#グリッド線
ax1.grid()
    color= #色

#X軸ラベル
ax1.set_xlabel()

#Y軸ラベル
ax1.set_ylabel()

#背面色
ax1.set_facecolor()

#タイトル
ax1.title()

#目盛の設定
ax1.set_xticks(np.arange(0,1300,250))
     #引数は最小、最大、刻み
0
0
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
0
0