ライブラリのインポート[matplotlib]
pip install matplotlib
データの準備
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [200, 100, 300, 250, 400, 700, 650, 900, 600, 1000]
データの変換
nx = np.array(x)
ny = np.array(y)
グラフの種類選択
縦棒グラフ
plt.bar(nx,ny)
横棒グラフ
plt.barh(nx,ny)
折れ線グラフ
plt.plot(nx,ny)
散布図
plt.scatter(nx,ny)
グラフの表示
plt.show()
結果
縦棒グラフ
![](https://tech.playground.style/tech/wp-content/uploads/2021/07/plot_bar-300x225.png)
横棒グラフ
![](https://tech.playground.style/tech/wp-content/uploads/2021/07/plot_barh-300x225.png)
折れ線グラフ
![](https://tech.playground.style/tech/wp-content/uploads/2021/07/plot_plot-300x225.png)
散布図
![](https://tech.playground.style/tech/wp-content/uploads/2021/07/plot_scatter-300x225.png)
ABOUT ME
![](https://tech.playground.style/tech/wp-content/uploads/2020/02/Umatani.jpg)
株式会社Playgroundのサービス
- 無料・簡単・片手でホームページを作成できる自社サービス Rakwi
- Web制作とアプリ開発を学べるオンラインプログラミング講座 Upstairs
- 開発,DX推進支援サービス スタートアッププラン